Skip to content

Latest commit

 

History

History
36 lines (23 loc) · 1.12 KB

op_handlers.md

File metadata and controls

36 lines (23 loc) · 1.12 KB

Operation Handlers

Operation Handlers in Huma

Operation Handlers are used in Huma to modify an operation before registration.

type OperationHandler func(op *huma.Operation)

Normally, they are passed to huma.Get(), huma.Post(), etc. functions as the last arguments.

Hureg usage

With hureg you still can use them as usual, but you can also add them to the APIGen instance to apply them to all operations registered with this instance.

derivedApi := api.AddOpHandler(oh1, oh2)

When you do so, oh1 and oh2 will be converted to Registration Middlewares and added to the new APIGen instance.

Normally, you don't need the full power of Registration Middlewares and can use Operation Handlers for most of the cases where you need to modify an operation before registration but don't need to perform multiple registration or prevent registration at all.

Built-in Operation Handlers

The library provides the most commonly needed Operation Handlers in the op_handlers package.


Extended operation metadata →