@@ -281,25 +281,53 @@ func loadDencoSingle(method, path string, h denco.HandlerFunc) http.Handler {
281
281
}
282
282
283
283
// Echo
284
- func echoHandler (* echo.Context ) error { return nil }
284
+ func echoHandler (c * echo.Context ) error {
285
+ return nil
286
+ }
285
287
286
288
func echoHandlerWrite (c * echo.Context ) error {
287
289
io .WriteString (c .Response , c .Param ("name" ))
288
290
return nil
289
291
}
290
292
291
293
func loadEcho (routes []route ) http.Handler {
292
- router := echo .New (). Router
294
+ e := echo .New ()
293
295
for _ , r := range routes {
294
- router .Add (r .method , r .path , echoHandler , nil )
296
+ switch r .method {
297
+ case "GET" :
298
+ e .Get (r .path , echoHandler )
299
+ case "POST" :
300
+ e .Post (r .path , echoHandler )
301
+ case "PUT" :
302
+ e .Put (r .path , echoHandler )
303
+ case "PATCH" :
304
+ e .Patch (r .path , echoHandler )
305
+ case "DELETE" :
306
+ e .Delete (r .path , echoHandler )
307
+ default :
308
+ panic ("Unknow HTTP method: " + r .method )
309
+ }
295
310
}
296
- return router
311
+ return e
297
312
}
298
313
299
- func loadEchoSingle (method , path string , handler echo. HandlerFunc ) http.Handler {
314
+ func loadEchoSingle (method , path string , h interface {} ) http.Handler {
300
315
e := echo .New ()
301
- e .MaxParam (20 )
302
- e .Router .Add (method , path , echoHandler , nil )
316
+ e .MaxParam (20 ) // TODO: technically illegal!
317
+ switch method {
318
+ case "GET" :
319
+ e .Get (path , h )
320
+ case "POST" :
321
+ e .Post (path , h )
322
+ case "PUT" :
323
+ e .Put (path , h )
324
+ case "PATCH" :
325
+ e .Patch (path , h )
326
+ case "DELETE" :
327
+ e .Delete (path , h )
328
+ default :
329
+ panic ("Unknow HTTP method: " + method )
330
+ }
303
331
return e .Router
304
332
}
305
333
0 commit comments