Skip to content

Add support for strict server with Gorilla#716

Merged
4 commits merged into
oapi-codegen:masterfrom
knazarenko-ptc:strict-gorilla
Aug 12, 2022
Merged

Add support for strict server with Gorilla#716
4 commits merged into
oapi-codegen:masterfrom
knazarenko-ptc:strict-gorilla

Conversation

@DouglasDwyer

Copy link
Copy Markdown
Contributor

This PR adds an extra template which supports strict server generation with Gorilla mux. The template is very similar to the Chi server template.

@Warboss-rus

Copy link
Copy Markdown
Contributor

Why not just use chi template and generate it for gorilla? There is no router-specific code in strict templates

@DouglasDwyer

Copy link
Copy Markdown
Contributor Author

Agreed - there is no router-specific code in the Chi server template, so it could work in lieu of something Gorilla-specific. Currently, calling oapi-codegen with the gorilla and strict options just doesn't generate the strict server implementation at all. Should I replace the reference to the Gorilla template in operations.go with a reference to Chi server? If we choose to do this, might it make more sense to rename the strict Chi server to something more neutral (like StrictHTTPServer)?

@Warboss-rus

Copy link
Copy Markdown
Contributor

Yeah, you can rename the template to strict-http and generate it for both chi and gorilla

@DouglasDwyer

Copy link
Copy Markdown
Contributor Author

Sounds good. I've gone ahead and made the requested changes.

@Warboss-rus Warboss-rus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@jamietanna jamietanna requested a review from a user August 12, 2022 17:09
@jamietanna

Copy link
Copy Markdown
Member

This would close #714 if merged - thanks for raising, quick glance on mobile looks good, but will have a proper review later 🤞🏽

@ghost

ghost commented Aug 12, 2022

Copy link
Copy Markdown

It looks like the generated files need to be regenerated for precommit to pass.

@ghost ghost merged commit fec990c into oapi-codegen:master Aug 12, 2022
adrianpk pushed a commit to foorester/oapi-codegen that referenced this pull request Jan 16, 2024
* Create strict-gorilla.tmpl

* Add Gorilla template

* Abstract strict HTTP server

* Regenerate samples

Co-authored-by: Dwyer <dodwyer@ptc.com>
adrianpk added a commit to foorester/oapi-codegen that referenced this pull request May 31, 2024
* Create strict-gorilla.tmpl

* Add Gorilla template

* Abstract strict HTTP server

* Regenerate samples

Co-authored-by: Dwyer <dodwyer@ptc.com>
This pull request was closed.
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