Skip to content

Commit 33be5f6

Browse files
Merge pull request #71 from cobomi/master
updated for current versions
2 parents 2b13695 + 69a8b77 commit 33be5f6

File tree

3 files changed

+36
-37
lines changed

3 files changed

+36
-37
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sudo: false
22
language: go
33
go:
4-
- 1.4
4+
- 1.8
55
- tip

routers.go

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
// - Keep the benchmark functions etc. alphabetically sorted
1818
// - Make a pull request (without benchmark results) at
1919
// https://github.com/julienschmidt/go-http-routing-benchmark
20-
"github.com/Unknwon/macaron"
2120
"github.com/ant0ine/go-json-rest/rest"
2221
"github.com/astaxie/beego"
2322
"github.com/astaxie/beego/context"
@@ -27,6 +26,7 @@ import (
2726
"github.com/dimfeld/httptreemux"
2827
"github.com/emicklei/go-restful"
2928
"github.com/gin-gonic/gin"
29+
"github.com/go-macaron/macaron"
3030
"github.com/go-martini/martini"
3131
"github.com/go-zoo/bone"
3232
"github.com/gocraft/web"
@@ -53,7 +53,6 @@ import (
5353
goji "github.com/zenazn/goji/web"
5454
gojiv2 "goji.io"
5555
gojiv2pat "goji.io/pat"
56-
gcontext "golang.org/x/net/context"
5756
)
5857

5958
type route struct {
@@ -330,59 +329,59 @@ func loadDencoSingle(method, path string, h denco.HandlerFunc) http.Handler {
330329
}
331330

332331
// Echo
333-
func echoHandler(c *echo.Context) error {
332+
func echoHandler(c echo.Context) error {
334333
return nil
335334
}
336335

337-
func echoHandlerWrite(c *echo.Context) error {
336+
func echoHandlerWrite(c echo.Context) error {
338337
io.WriteString(c.Response(), c.Param("name"))
339338
return nil
340339
}
341340

342-
func echoHandlerTest(c *echo.Context) error {
341+
func echoHandlerTest(c echo.Context) error {
343342
io.WriteString(c.Response(), c.Request().RequestURI)
344343
return nil
345344
}
346345

347346
func loadEcho(routes []route) http.Handler {
348-
var h interface{} = echoHandler
349-
if loadTestHandler {
347+
var h echo.HandlerFunc = echoHandler
348+
if loadTestHandler {
350349
h = echoHandlerTest
351350
}
352351

353352
e := echo.New()
354353
for _, r := range routes {
355354
switch r.method {
356355
case "GET":
357-
e.Get(r.path, h)
356+
e.GET(r.path, h)
358357
case "POST":
359-
e.Post(r.path, h)
358+
e.POST(r.path, h)
360359
case "PUT":
361-
e.Put(r.path, h)
360+
e.PUT(r.path, h)
362361
case "PATCH":
363-
e.Patch(r.path, h)
362+
e.PATCH(r.path, h)
364363
case "DELETE":
365-
e.Delete(r.path, h)
364+
e.DELETE(r.path, h)
366365
default:
367366
panic("Unknow HTTP method: " + r.method)
368367
}
369368
}
370369
return e
371370
}
372371

373-
func loadEchoSingle(method, path string, h interface{}) http.Handler {
372+
func loadEchoSingle(method, path string, h echo.HandlerFunc) http.Handler {
374373
e := echo.New()
375374
switch method {
376375
case "GET":
377-
e.Get(path, h)
376+
e.GET(path, h)
378377
case "POST":
379-
e.Post(path, h)
378+
e.POST(path, h)
380379
case "PUT":
381-
e.Put(path, h)
380+
e.PUT(path, h)
382381
case "PATCH":
383-
e.Patch(path, h)
382+
e.PATCH(path, h)
384383
case "DELETE":
385-
e.Delete(path, h)
384+
e.DELETE(path, h)
386385
default:
387386
panic("Unknow HTTP method: " + method)
388387
}
@@ -532,13 +531,13 @@ func loadGojiSingle(method, path string, handler interface{}) http.Handler {
532531
}
533532

534533
// goji v2 (github.com/goji/goji)
535-
func gojiv2Handler(ctx gcontext.Context, w http.ResponseWriter, r *http.Request) {}
534+
func gojiv2Handler(w http.ResponseWriter, r *http.Request) {}
536535

537-
func gojiv2HandlerWrite(ctx gcontext.Context, w http.ResponseWriter, r *http.Request) {
538-
io.WriteString(w, gojiv2pat.Param(ctx, "name"))
536+
func gojiv2HandlerWrite(w http.ResponseWriter, r *http.Request) {
537+
io.WriteString(w, gojiv2pat.Param(r, "name"))
539538
}
540539

541-
func gojiv2HandlerTest(ctx gcontext.Context, w http.ResponseWriter, r *http.Request) {
540+
func gojiv2HandlerTest(w http.ResponseWriter, r *http.Request) {
542541
io.WriteString(w, r.RequestURI)
543542
}
544543

@@ -552,35 +551,35 @@ func loadGojiv2(routes []route) http.Handler {
552551
for _, route := range routes {
553552
switch route.method {
554553
case "GET":
555-
mux.HandleFuncC(gojiv2pat.Get(route.path), h)
554+
mux.HandleFunc(gojiv2pat.Get(route.path), h)
556555
case "POST":
557-
mux.HandleFuncC(gojiv2pat.Post(route.path), h)
556+
mux.HandleFunc(gojiv2pat.Post(route.path), h)
558557
case "PUT":
559-
mux.HandleFuncC(gojiv2pat.Put(route.path), h)
558+
mux.HandleFunc(gojiv2pat.Put(route.path), h)
560559
case "PATCH":
561-
mux.HandleFuncC(gojiv2pat.Patch(route.path), h)
560+
mux.HandleFunc(gojiv2pat.Patch(route.path), h)
562561
case "DELETE":
563-
mux.HandleFuncC(gojiv2pat.Delete(route.path), h)
562+
mux.HandleFunc(gojiv2pat.Delete(route.path), h)
564563
default:
565564
panic("Unknown HTTP method: " + route.method)
566565
}
567566
}
568567
return mux
569568
}
570569

571-
func loadGojiv2Single(method, path string, handler gojiv2.HandlerFunc) http.Handler {
570+
func loadGojiv2Single(method, path string, handler func(http.ResponseWriter, *http.Request)) http.Handler {
572571
mux := gojiv2.NewMux()
573572
switch method {
574573
case "GET":
575-
mux.HandleFuncC(gojiv2pat.Get(path), handler)
574+
mux.HandleFunc(gojiv2pat.Get(path), handler)
576575
case "POST":
577-
mux.HandleFuncC(gojiv2pat.Post(path), handler)
576+
mux.HandleFunc(gojiv2pat.Post(path), handler)
578577
case "PUT":
579-
mux.HandleFuncC(gojiv2pat.Put(path), handler)
578+
mux.HandleFunc(gojiv2pat.Put(path), handler)
580579
case "PATCH":
581-
mux.HandleFuncC(gojiv2pat.Patch(path), handler)
580+
mux.HandleFunc(gojiv2pat.Patch(path), handler)
582581
case "DELETE":
583-
mux.HandleFuncC(gojiv2pat.Delete(path), handler)
582+
mux.HandleFunc(gojiv2pat.Delete(path), handler)
584583
default:
585584
panic("Unknow HTTP method: " + method)
586585
}
@@ -1255,11 +1254,11 @@ func loadRevelSingle(method, path, action string) http.Handler {
12551254
// Rivet
12561255
func rivetHandler() {}
12571256

1258-
func rivetHandlerWrite(c rivet.Context) {
1257+
func rivetHandlerWrite(c *rivet.Context) {
12591258
c.WriteString(c.Get("name"))
12601259
}
12611260

1262-
func rivetHandlerTest(c rivet.Context) {
1261+
func rivetHandlerTest(c *rivet.Context) {
12631262
c.WriteString(c.Req.RequestURI)
12641263
}
12651264

routers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var (
3636
{"R2router", loadR2router},
3737
{"Revel", loadRevel},
3838
{"Rivet", loadRivet},
39-
{"Tango", loadTango},
39+
//{"Tango", loadTango},
4040
{"TigerTonic", loadTigerTonic},
4141
{"Traffic", loadTraffic},
4242
{"Vulcan", loadVulcan},

0 commit comments

Comments
 (0)