-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
fix: NewRoute/NewBaseRoute to take engine not just OpeAPI for accepted content types #334
base: main
Are you sure you want to change the base?
Conversation
func NewBaseRoute(method, path string, handler any, openapi *OpenAPI, options ...func(*BaseRoute)) BaseRoute { | ||
func NewBaseRoute(method, path string, handler any, e *Engine, options ...func(*BaseRoute)) BaseRoute { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But do we really need this? For future compatibility maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figure we can just deprecate this function. You are just talking about the function right? Deprecating the Struct of BaseRoute would be a fairly large change which we'd probably want a separate PR for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I was talking about changing the *OpenAPI param to *engine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. It fixed the WithContentTypes option. I think the line you're missing is:
see the AcceptedContentTypes: e.acceptedContentTypes,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hence my 4 questions where do we want to put acceptedContentTypes
and how do we want to provide an option to configure it 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if that clarifies things. I personally don't mind acceptedContentTypes
existing on the Engine. At the very least I want avoid having to support a set of options for NewOpenAPI as we're getting to be pretty nested at that point.
So my preference is: 1 or 2
c36f782
to
8ed6f35
Compare
8ed6f35
to
1529578
Compare
…estContentTypes`
Relates to #333
Somewhere along implementing support for different engines this was lost. This is a bit disruptive as it's changing the
NewRoute/NewBaseRoute
. The other option would be to placeacceptedContentTypes
on ourOpenAPI
struct I could go either way. We wouldn't be changing theNewRoute
andNewBaseRoute
API in the case of the later, but again we'd need to support yet another nested structure with it's own options. I think flattening in the Engine is OK, I guess 🤷.So the options are
acceptedContentTypes
in theOpenAPI
struct. We can could then do something likeacceptedContentTypes
in theOpenAPI
struct. And expose aWithOpenAPIOptions
. At this point we're nesting pretty deep...OpenAPIConfig
struct as well. Then engine would still need to be passed to theNew*Route
funcs.Cheers