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

Not possible to create Router without framework #525

Open
thomacco opened this issue Feb 14, 2022 · 4 comments
Open

Not possible to create Router without framework #525

thomacco opened this issue Feb 14, 2022 · 4 comments

Comments

@thomacco
Copy link

Hello,

My team is trying to have as less depencies as possible and currently it seems not to be possible to generate code that does not have any routing frameworks.
I really like your project but one idiom of GO is to have as less dependencies that possible.

Is there a way to accomplish that with oapi-codegen or is using chi-router the next best thing?

@deepmap-marcinr
Copy link
Contributor

Do you mean dependencies in terms of our own go.mod? We have lots of dependencies because we generate code for many different routers, and in order to test them, we need those packages.

However, if you generate a chi server with minimal options, the generated code should not have that many dependencies, but our pkg/runtime will drag in some dependencies.

My goal initially was to have the generated files be self contained, but I've not had time to do that, and other people's packages solve really hard problems, like request validation.

@jamietanna
Copy link
Member

We could look at producing a net/http router, for as limited a router as possible, but chi/gorilla provide a much better experience that I'd recommend it if possible.

@deepmap-marcinr
Copy link
Contributor

IMO, this is one of those "opinionated" decisions that make a lot of other things easier. People have built fantastic http Routers, and it's a duplication of effort to re-create that here, spending years re-learning their mistakes.

I originally started with echo after having heavily used Gin/Echo. I chose Echo over Gin because the Context in Echo is an interface, and easier to mock for various reasons, while it's a struct pointer in Gin. Then, others added different routers like Chi.

For minimal dependencies, you could use the code to generate only the models, and simply unmarshal from JSON yourself, no routing frameworks required at runtime.

@jamietanna
Copy link
Member

This will be closed when #1068 is implemented

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

No branches or pull requests

3 participants