Skip to content

Commit

Permalink
Re-exports FuncName as public function
Browse files Browse the repository at this point in the history
  • Loading branch information
EwenQuim committed Dec 13, 2024
1 parent 8964e3f commit 5a337b2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func Handle(s *Server, path string, controller http.Handler, options ...func(*Ba
return Register(s, Route[any, any]{
BaseRoute: BaseRoute{
Path: path,
FullName: funcName(controller),
FullName: FuncName(controller),
},
}, controller)
}
Expand Down Expand Up @@ -179,7 +179,7 @@ func registerFuegoController[T, B any, Contexted ctx[B]](s *Server, method, path
Method: method,
Path: path,
Params: make(map[string]OpenAPIParam),
FullName: funcName(controller),
FullName: FuncName(controller),
Operation: openapi3.NewOperation(),
OpenAPI: s.OpenAPI,
}
Expand All @@ -199,7 +199,7 @@ func registerStdController(s *Server, method, path string, controller func(http.
route := BaseRoute{
Method: method,
Path: path,
FullName: funcName(controller),
FullName: FuncName(controller),
Operation: openapi3.NewOperation(),
OpenAPI: s.OpenAPI,
}
Expand All @@ -218,8 +218,8 @@ func withMiddlewares(controller http.Handler, middlewares ...func(http.Handler)
return controller
}

// funcName returns the name of a function and the name with package path
func funcName(f interface{}) string {
// FuncName returns the name of a function and the name with package path
func FuncName(f interface{}) string {
return strings.TrimSuffix(runtime.FuncForPC(reflect.ValueOf(f).Pointer()).Name(), "-fm")
}

Expand Down

0 comments on commit 5a337b2

Please sign in to comment.