-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Milestone
Description
Currently std-http-server handles a root path(/) in an spec with this generated code:
m.HandleFunc("GET "+options.BaseURL+"/", wrapper.Get)
According to net/http docs:
Patterns can match the method, host and path of a request. Some examples:
- "/index.html" matches the path "/index.html" for any host and method.
- "GET /static/" matches a GET request whose path begins with "/static/".
- "example.com/" matches any request to the host "example.com".
- "example.com/{$}" matches requests with host "example.com" and path "/".
- "/b/{bucket}/o/{objectname...}" matches paths whose first segment is "b" and whose third segment is "o". The name "bucket" denotes the second segment and "objectname" denotes the remainder of the path.
So, with this pattern would match all paths.
OpenAPI to my understanding doesn't allow wildcard paths, which this essentially is- also without outside validation it would never return a 404.
But I do think a wildcard method would be useful, and it is possible(though not openapi supported) by doing
/public/{path...}:
get:
parameters:
- name: path...
in: path
required: true
schema:
type: stringThe problem is the generated parameter binding is:
err = runtime.BindStyledParameterWithOptions("simple", "path...", r.PathValue("path..."), &path, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})When the parameter name that net/http gives it is just path