Skip to content

Wrap Chi server and pass parameters as function params#166

Merged
deepmap-marcinr merged 5 commits intooapi-codegen:masterfrom
qmuntal:chipath
Jul 20, 2020
Merged

Wrap Chi server and pass parameters as function params#166
deepmap-marcinr merged 5 commits intooapi-codegen:masterfrom
qmuntal:chipath

Conversation

@qmuntal
Copy link
Contributor

@qmuntal qmuntal commented Apr 2, 2020

Wrap the Chi server in the same way it is being done with Echo:

  • Pass in mandatory path arguments as function arguments
  • Pass in query, header and cookie params struct only if there is at least on parameter of these types.

This way the resulting code is more symmetric with Echo and path parameters can be obtained with consulting opaque context values.

The http.ResponseWriter and http.Request are still passed to the server interface because the server is still responsible of writing the response and not all entities are yet managed by the auto generated code, such as decoding the request.Body.

@dannymidnight
Copy link
Contributor

This is something that's come up in the past #56 (comment) and looks like a decent change 👍

@deepmap-marcinr deepmap-marcinr merged commit e232d16 into oapi-codegen:master Jul 20, 2020
@pgolm
Copy link
Contributor

pgolm commented Jul 24, 2020

Awesome improvement 👍 . But unfortunately this is a breaking change. I'm not sure if this project uses semver, but it would be nice if you could release this as major change instead as patch the next time.

@deepmap-marcinr
Copy link
Contributor

deepmap-marcinr commented Jul 24, 2020 via email

@ashwinrs
Copy link
Contributor

It broke our pipeline as well. We should try and avoid breaking changes to be introduced without updating the major version. Or find another alternative.

adrianpk pushed a commit to foorester/oapi-codegen that referenced this pull request Jan 16, 2024
)

* wrap server interface

* pass request and response to the handlers

* update examples and tests

* fix chi template
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.

5 participants