Documentation
¶
Index ¶
- Variables
- func AsHandler(f any, anns ...fx.Annotation) any
- func AsMiddleware(middleware any) any
- func AsMiddlewareFunc(name string, ...) any
- func NewAdapter(r *echo.Echo, g *echo.Group) huma.Adapter
- func Operation(base ...Option) func(...Option) huma.Operation
- func Register[I, O any](api huma.API, handler func(context.Context, *I) (*O, error), ...)
- func Transform[I, O any](errorTransform ErrorTransformerFunc, ...) func(context.Context, *I) (*O, error)
- func WithCreated(op *huma.Operation)
- func WithDelete(op *huma.Operation)
- func WithGet(op *huma.Operation)
- func WithNoContent(op *huma.Operation)
- func WithOK(op *huma.Operation)
- func WithPatch(op *huma.Operation)
- func WithPost(op *huma.Operation)
- func WithPut(op *huma.Operation)
- type Authorizer
- type CRUD
- type CRUDInfo
- type Create
- type CreateInput
- type CreateResponse
- type Delete
- type DeleteMany
- type ErrorTransformerFunc
- type Handler
- type IDInput
- type IDsInput
- type List
- type ListInput
- type ListOutput
- type Middleware
- type Option
- func WithAddPath(path string) Option
- func WithAddTags(tags ...string) Option
- func WithDefaultStatus(status int) Option
- func WithDescription(description string) Option
- func WithMetadata(metadata map[string]any) Option
- func WithMetadataItem(key string, value any) Option
- func WithMethod(method string) Option
- func WithOperationID(operationID string) Option
- func WithPath(path string) Option
- func WithSecurity(security []map[string][]string) Option
- func WithSummary(summary string) Option
- func WithTags(tags ...string) Option
- type Read
- type Response
- type Update
- type UpdateInput
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultAnnotations = []fx.Annotation{ fx.As(new(Handler)), fx.ResultTags(`group:"api-handler"`), }
View Source
var MultipartMaxMemory int64 = 8 * 1024
MultipartMaxMemory is the maximum memory to use when parsing multipart form data.
Functions ¶
func AsMiddleware ¶ added in v0.0.5
func AsMiddlewareFunc ¶ added in v0.0.5
func WithCreated ¶
func WithDelete ¶
func WithNoContent ¶
Types ¶
type Authorizer ¶ added in v0.0.5
type CRUD ¶
type CRUD[
CB interface {
Decode(context.Context, *M) error
},
UB interface {
Decode(context.Context, *M) error
},
M any,
ID any,
] struct {
Info CRUDInfo
List[M]
Read[M, ID]
Create[CB, M, ID]
Update[UB, M, ID]
Delete[ID]
DeleteMany[ID]
}
type Create ¶
type Create[B interface {
Decode(context.Context, *M) error
}, M any, ID any] struct {
Saver func(context.Context, *M) error
Location func(string, M) *CreateResponse
ErrorTransformer ErrorTransformerFunc
Operation huma.Operation
}
func (Create[B, M, ID]) Handler ¶
func (h Create[B, M, ID]) Handler(ctx context.Context, in *CreateInput[B]) (*CreateResponse, error)
type CreateInput ¶
type CreateInput[B any] struct { Body B }
type CreateResponse ¶
type CreateResponse struct {
Location string `header:"Content-Location"`
}
type Delete ¶
type Delete[ID any] struct { Deleter func(context.Context, ...ID) error ErrorTransformer ErrorTransformerFunc Operation huma.Operation }
type DeleteMany ¶
type DeleteMany[ID any] struct { Deleter func(context.Context, ...ID) error ErrorTransformer ErrorTransformerFunc Operation huma.Operation }
func NewDeleteMany ¶
func NewDeleteMany[ID any]( deleter func(context.Context, ...ID) error, errorTransformer ErrorTransformerFunc, operation huma.Operation, ) DeleteMany[ID]
type IDsInput ¶
type IDsInput[ID any] struct { IDs []ID `query:"ids" required:"true" minItems:"1" nullable:"false"` }
type List ¶
type List[M any] struct { Finder func(context.Context, *cr.Criteria) ([]M, int, error) ErrorTransformer ErrorTransformerFunc Operation huma.Operation }
type ListInput ¶
type ListInput struct {
Page int `query:"page" json:"page,omitempty" yaml:"page,omitempty" required:"false"`
Limit int `query:"limit" json:"limit,omitempty" yaml:"limit,omitempty" required:"false"`
Sort string `query:"sort" json:"sort,omitempty" yaml:"sort,omitempty" required:"false"`
Filter string `query:"filter" json:"filter,omitempty" yaml:"filter,omitempty" required:"false"`
}
type ListOutput ¶
type Middleware ¶ added in v0.0.5
type Middleware struct {
Name string
Middleware func(huma.API) func(huma.Context, func(huma.Context))
}
func AuthorizationMiddleware ¶ added in v0.0.5
func AuthorizationMiddleware(authorizer Authorizer, logger *zap.Logger) Middleware
func NewMiddleware ¶ added in v0.0.5
type Option ¶
func WithAddPath ¶
func WithAddTags ¶
func WithDefaultStatus ¶
func WithDescription ¶
func WithMetadata ¶
func WithMetadataItem ¶
func WithMethod ¶
func WithOperationID ¶
func WithSecurity ¶
func WithSummary ¶
type Read ¶
type Read[M any, ID any] struct { Finder func(context.Context, ID) (M, error) ErrorTransformer ErrorTransformerFunc Operation huma.Operation }
type Update ¶
type Update[B interface {
Decode(context.Context, *M) error
}, M any, ID any] struct {
Finder func(context.Context, ID) (M, error)
Saver func(context.Context, *M) error
ErrorTransformer ErrorTransformerFunc
Operation huma.Operation
}
type UpdateInput ¶
Click to show internal directories.
Click to hide internal directories.