oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

feat: implement x-oapi-codegen-middlewares (#461)

Open hhhapz opened this issue 3 years ago • 3 comments

This change adds the x-oapi-codegen-middlewares extension tag for the chi server and a new TaggedMiddleware field to the server interface. This makes it possible for users to define middlewares that are only called on specific endpoints, and also allows middlewares to be reused. The middlewares are called after the global middlewares, and in the order they are defined.

This change is fully backwards compatible with all older versions of oapi-codegen, however one disadvantage to this is the silent failure when a tagged middleware was not found. Perhaps that can be changed in v2.

Closes #461

hhhapz avatar Oct 09 '21 05:10 hhhapz

would be very useful great work! need any help ?

thejdavid avatar Nov 21 '21 01:11 thejdavid

would be very useful great work! need any help ?

hey, this has already been implemented and further improved upon in a fork that myself and other people in the discord gophers community are maintaining. You can check it out at https://github.com/discord-gophers/goapi-gen

hhhapz avatar Nov 21 '21 03:11 hhhapz

@hhhapz Did you found some temporary solution?

aaletov avatar Jan 20 '23 14:01 aaletov