Blame vendor/github.com/deepmap/oapi-codegen/pkg/codegen/templates/chi-handler.tmpl
|
Packit Service |
3a6627 |
// Handler creates http.Handler with routing matching OpenAPI spec.
|
|
Packit Service |
3a6627 |
func Handler(si ServerInterface) http.Handler {
|
|
Packit Service |
3a6627 |
return HandlerFromMux(si, chi.NewRouter())
|
|
Packit Service |
3a6627 |
}
|
|
Packit Service |
3a6627 |
|
|
Packit Service |
3a6627 |
// HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.
|
|
Packit Service |
3a6627 |
func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler {
|
|
Packit Service |
3a6627 |
{{if .}}wrapper := ServerInterfaceWrapper{
|
|
Packit Service |
3a6627 |
Handler: si,
|
|
Packit Service |
3a6627 |
}
|
|
Packit Service |
3a6627 |
{{end}}
|
|
Packit Service |
3a6627 |
{{range .}}r.Group(func(r chi.Router) {
|
|
Packit Service |
3a6627 |
r.{{.Method | lower | title }}("{{.Path | swaggerUriToChiUri}}", wrapper.{{.OperationId}})
|
|
Packit Service |
3a6627 |
})
|
|
Packit Service |
3a6627 |
{{end}}
|
|
Packit Service |
3a6627 |
return r
|
|
Packit Service |
3a6627 |
}
|