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

gin: included middleware cannot abort request #485

Open
erikbos opened this issue Nov 17, 2021 · 3 comments
Open

gin: included middleware cannot abort request #485

erikbos opened this issue Nov 17, 2021 · 3 comments

Comments

@erikbos
Copy link

erikbos commented Nov 17, 2021

For Gin generated code, when supplying middleware:

	RegisterHandlersWithOptions(router, handler, GinServerOptions{
		Middlewares: []MiddlewareFunc{
			auth.AuthenticateAndAuthorize,
		},
	})

A request cannot be abort by middleware, the request is fully being handled.. which mean authentication middleware cannot abort a request for example.

(@stephen-opal noticed the issue in initial pull request: #385 (comment))

@tomsharratt
Copy link

Any chance this will be getting resolved?

@re-cheid
Copy link

For the time being you can just take my modified gin template files from #926 and use them as custom templates during generation as described here: https://github.com/deepmap/oapi-codegen#making-changes-to-code-generation

I just put them in my project directory:
image

Then I call oapi-codegen -generate gin -templates scripts/oapi-codegen-templates/ -o "gen/openapi/openapi_api.gen.go" -package "rest_service" "api/openapi/rest_service.yaml"

@alexstojda
Copy link
Contributor

This should be resolved by #914, @deepmap-marcinr probably good to close this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants