Skip to content
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

Merged
merged 3 commits into from
Jan 13, 2025

Conversation

dylanhitt
Copy link
Collaborator

@dylanhitt dylanhitt commented Jan 7, 2025

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 place acceptedContentTypes on our OpenAPI struct I could go either way. We wouldn't be changing the NewRoute and NewBaseRoute 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

  1. This PR. Just be fine with configuration occurring on the engine struct
  2. Place acceptedContentTypes in the OpenAPI struct. We can could then do something like
func WithRequestContentType(consumes ...string) func(*Engine) {
	return func(e *Engine) { e.OpenAPI.acceptedContentTypes = consumes }
}
  1. Place acceptedContentTypes in the OpenAPI struct. And expose a WithOpenAPIOptions. At this point we're nesting pretty deep...
  2. This could exist on the OpenAPIConfig struct as well. Then engine would still need to be passed to the New*Route funcs.

Cheers

server.go Show resolved Hide resolved
server_test.go Show resolved Hide resolved
route.go Show resolved Hide resolved
@dylanhitt dylanhitt force-pushed the BREAKING/engine.WithRequestContentType.fix branch from 8ed6f35 to 1529578 Compare January 8, 2025 17:47
@dylanhitt dylanhitt requested a review from EwenQuim January 9, 2025 17:00
@dylanhitt
Copy link
Collaborator Author

I'm going to go ahead and merge this unless anyone objects.

@EwenQuim
Copy link
Member

Looking at it again right now

Copy link
Member

@EwenQuim EwenQuim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect. Sorry for the long review delay!

@dylanhitt
Copy link
Collaborator Author

Perfect. Sorry for the long review delay!

Thank you. Sorry been a bit impatient. Been thinking about #341 a bunch and i know this would cause conflicts.

@dylanhitt dylanhitt merged commit 7e11551 into main Jan 13, 2025
9 checks passed
@dylanhitt dylanhitt deleted the BREAKING/engine.WithRequestContentType.fix branch January 13, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants