From dea234d0b16931afd52a3b136397732d653cbbcb Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 14 Dec 2018 16:34:42 +0100 Subject: [PATCH] export RequestHandler --- route.go | 10 +++++----- route_handler.go | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/route.go b/route.go index c03e3f77..b119d740 100644 --- a/route.go +++ b/route.go @@ -87,25 +87,25 @@ func (r *Router) GetMiddleware(name string) *Middleware { } // Get register a GET request handle with the given path -func (r *Router) Get(path string, handle requestHandler, config ...*RouteConfig) { +func (r *Router) Get(path string, handle RequestHandler, config ...*RouteConfig) { r.routers["GET"] = append(r.routers["GET"], newRouteHandler(path, handle, config...)) r.sortRoutes(r.routers["GET"]) } // Post register a POST request handle with the given path -func (r *Router) Post(path string, handle requestHandler, config ...*RouteConfig) { +func (r *Router) Post(path string, handle RequestHandler, config ...*RouteConfig) { r.routers["POST"] = append(r.routers["POST"], newRouteHandler(path, handle, config...)) r.sortRoutes(r.routers["POST"]) } // Put register a PUT request handle with the given path -func (r *Router) Put(path string, handle requestHandler, config ...*RouteConfig) { +func (r *Router) Put(path string, handle RequestHandler, config ...*RouteConfig) { r.routers["PUT"] = append(r.routers["PUT"], newRouteHandler(path, handle, config...)) r.sortRoutes(r.routers["PUT"]) } // Delete register a DELETE request handle with the given path -func (r *Router) Delete(path string, handle requestHandler, config ...*RouteConfig) { +func (r *Router) Delete(path string, handle RequestHandler, config ...*RouteConfig) { r.routers["DELETE"] = append(r.routers["DELETE"], newRouteHandler(path, handle, config...)) r.sortRoutes(r.routers["DELETE"]) } @@ -322,7 +322,7 @@ func (admin *Admin) RegisterResourceRouters(res *Resource, actions ...string) { } // RegisterRoute register route -func (res *Resource) RegisterRoute(method string, relativePath string, handler requestHandler, config *RouteConfig) { +func (res *Resource) RegisterRoute(method string, relativePath string, handler RequestHandler, config *RouteConfig) { if config == nil { config = &RouteConfig{} } diff --git a/route_handler.go b/route_handler.go index 5faf2515..54ff037c 100644 --- a/route_handler.go +++ b/route_handler.go @@ -15,15 +15,15 @@ type RouteConfig struct { Values map[interface{}]interface{} } -type requestHandler func(c *Context) +type RequestHandler func(c *Context) type routeHandler struct { Path string - Handle requestHandler + Handle RequestHandler Config *RouteConfig } -func newRouteHandler(path string, handle requestHandler, configs ...*RouteConfig) *routeHandler { +func newRouteHandler(path string, handle RequestHandler, configs ...*RouteConfig) *routeHandler { handler := &routeHandler{ Path: "/" + strings.TrimPrefix(path, "/"), Handle: handle,