Skip to content

Commit 888df4d

Browse files
author
Miguel Silva
committed
feat: add Echo v5 server support and example
- Add HandlerKindEchoV5 constant and IsValid() support in configuration.go - Add echo-v5 handler, middleware, and server templates - Add examples/server/echo-v5 standalone example with README - Add examples/server/test/echo-v5 test case wired into server_test.go - Add github.com/labstack/echo/v5 to examples/go.mod - Add echo-v5 to configuration-schema.json handler kind enum - Add echo-v5 router init test in integration_test.go
1 parent d92daca commit 888df4d

File tree

21 files changed

+4714
-2
lines changed

21 files changed

+4714
-2
lines changed

configuration-schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@
276276
},
277277
"kind": {
278278
"type": "string",
279-
"enum": ["beego", "chi", "echo", "fasthttp", "fiber", "gin", "goframe", "go-zero", "gorilla-mux", "hertz", "iris", "kratos", "std-http"],
279+
"enum": ["beego", "chi", "echo", "echo-v5", "fasthttp", "fiber", "gin", "goframe", "go-zero", "gorilla-mux", "hertz", "iris", "kratos", "std-http"],
280280
"description": "Router/framework to generate for. Required."
281281
},
282282
"models-package-alias": {

examples/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ require (
8686
github.com/kataras/tunnel v0.0.4 // indirect
8787
github.com/klauspost/compress v1.18.4 // indirect
8888
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
89+
github.com/labstack/echo/v5 v5.1.0 // indirect
8990
github.com/labstack/gommon v0.4.2 // indirect
9091
github.com/leodido/go-urn v1.4.0 // indirect
9192
github.com/magiconair/properties v1.8.10 // indirect

examples/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
181181
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
182182
github.com/labstack/echo/v4 v4.15.0 h1:hoRTKWcnR5STXZFe9BmYun9AMTNeSbjHi2vtDuADJ24=
183183
github.com/labstack/echo/v4 v4.15.0/go.mod h1:xmw1clThob0BSVRX1CRQkGQ/vjwcpOMjQZSZa9fKA/c=
184+
github.com/labstack/echo/v5 v5.1.0 h1:MvIRydoN+p9cx/zq8Lff6YXqUW2ZaEsOMISzEGSMrBI=
185+
github.com/labstack/echo/v5 v5.1.0/go.mod h1:SyvlSdObGjRXeQfCCXW/sybkZdOOQZBmpKF0bvALaeo=
184186
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
185187
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
186188
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=

examples/server/echo-v5/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Echo v5 Server Example
2+
3+
This example demonstrates server code generation using [Echo v5](https://github.com/labstack/echo), a high-performance, minimalist Go web framework.
4+
5+
## Description
6+
7+
- Echo v5 uses `echo.MiddlewareFunc` for middleware (handler signature changed to `func(c *echo.Context) error`)
8+
- Path parameters are extracted via `c.PathParam("paramName")`
9+
- Echo v5 uses a pointer receiver `*echo.Context` instead of the v4 interface
10+
- Built-in middleware available: `middleware.Recover()`, `middleware.Logger()`, `middleware.CORS()`, etc.
11+
- Graceful shutdown is handled via `echo.StartConfig.Start(ctx, e)`
12+
13+
## Integrating with Existing Server
14+
15+
If you already have an Echo v5 instance, register the generated routes:
16+
17+
```go
18+
import handler "your/module/api"
19+
20+
svc := handler.NewService()
21+
handler.NewRouter(e, svc)
22+
```
23+
24+
## Running the Server
25+
26+
```bash
27+
go run ./server
28+
```
29+
30+
The server starts on port 8080.
31+
32+
## API Endpoints
33+
34+
### Health Check
35+
36+
```bash
37+
curl http://localhost:8080/health
38+
```
39+
40+
### List Users
41+
42+
```bash
43+
curl http://localhost:8080/users
44+
```
45+
46+
With optional limit parameter:
47+
48+
```bash
49+
curl "http://localhost:8080/users?limit=10"
50+
```
51+
52+
### Create User
53+
54+
```bash
55+
curl -X POST http://localhost:8080/users \
56+
-H "Content-Type: application/json" \
57+
-d '{"name": "John Doe", "email": "john@example.com"}'
58+
```
59+
60+
### Get User by ID
61+
62+
```bash
63+
curl http://localhost:8080/users/123
64+
```
65+
66+
### Delete User
67+
68+
```bash
69+
curl -X DELETE http://localhost:8080/users/123
70+
```

0 commit comments

Comments
 (0)