This package provides a set of Operation Handlers that plays well with hureg
library.
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.
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)
hureg.Get(derivedApi, "/cat", catHandler) // oh1 and oh2 will be applied to the operation
Package provides a set of Operation Handlers that can be used both in registration function (hureg.Get()
,
hureg.Post()
, ..., hureg.Register()
) and in APIGen.AddOpHandler()
method to apply them to all operations
registered with the APIGen
instance.
Even though the handlers follow the standard Huma func(op *huma.Operation)
signature, some of them require
operation metadata keys specific to hureg
library.
What can you do with provided Operation Handlers is:
- Add Security entries to the operation
- Add Tags to the operation
- Generate operationID - can be useful for explicitly defined operations
- Generate operation Summary - can be useful for explicitly defined operations
- Conditionally apply other handlers
- Add middlewares to the operation - there is a shortcut in
ApiGEN
for this - Set BodyReadTimeout field
- Set Deprecated field
- Set Description field
- Set Extension key
- Set ExternalDocs field
- Set Hidden field
- Set MaxBodyBytes field
- Set Metadata keys
- Set Responses key
- Set SkipValidateBody field
- Set Summary field
- Update generated Summary field after operation modification