-
Notifications
You must be signed in to change notification settings - Fork 12
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
Generated render/bind implementations #68
Comments
Closed by #47 ? |
Not exactly, This issue is about generating go-chi/render's functions directly alongside the generated code, avoiding the dependency. Since we already generate the implementation of interfaces, we just need the actual render implementation, which is quite small |
Correct, the goal of this issue is to simplify our dependencies. |
As a sidenote, I think we're better off changing the generated method signatures to return a func (h handler) Login(w http.ResponseWriter, r *http.Request, params openapi.LoginParams) *openapi.Response {
s, err := h.server.LoginServer().Login(
r.Context(),
params.Username, params.Password,
foodtinder.LoginMetadata{
UserAgent: r.Header.Get("User-Agent"),
},
)
if err != nil {
return openapi.LoginJSON400Response(openapi.Error{Error: err})
}
return openapi.LoginJSON200Response(openapi.Session{
UserID: openapi.ID(s.UserID),
Token: s.Token,
Expiry: s.Expiry,
Metadata: openapi.LoginMetadata{
UserAgent: optstr(s.Metadata.UserAgent),
},
})
} (package Created PR #80 to implement this. |
Currently we use https://github.com/go-chi/render interfaces for our generated types, simplifying request/response management.
I propose we implement our own alternative that is generated alongside server/type code.
A generated implementation removes the need for a dependency and allows us to easily modify it to suit any future needs (ie more content types).
The text was updated successfully, but these errors were encountered: