oapi-codegen
oapi-codegen copied to clipboard
Generate functions to get operation URLs
For handlers that generate links to other resources, it would be useful to be able to call a function that generates a URL for an operation. The current NewOperationRequest type functions could be split into two functions. Roughly like this:
func NewOperationRequest(server string, params *OperationParams) (*http.Request, error) {
operationURL, err := OperationURL(server, params)
if err != nil {
return nil, err
}
req, err := http.NewRequest("GET", operationURL.String(), nil)
if err != nil {
return nil, err
}
return req, nil
}
func OperationURL(server string, params *OperationParams) (*url.URL, error) {
// use existing logic to generate the URL...
}
Would a pull request for something like this be acceptable?
This would indeed be a really useful feature, especially when trying to implement HATEOAS. Another solution could be to use a URL store such as https://github.com/alehano/reverse.