Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export RequestHandler #158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions route.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
}
Expand Down Expand Up @@ -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{}
}
Expand Down
6 changes: 3 additions & 3 deletions route_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down