Documentation
¶
Index ¶
- Variables
- func ExposeMiddleware(ctx huma.Context, next func(huma.Context))
- func New(s server.I, name, version, description string, path string, sm *servemux.S)
- func NewHuma(router *servemux.S, name, version, description string) (api huma.API)
- type EventInput
- type EventOutput
- type ExportInput
- type ExportOutput
- type ImportInput
- type ImportOutput
- type OK
- type OKs
- type Operations
Constants ¶
This section is empty.
Variables ¶
var Ok = OKs{ Ok: func( a *Operations, eid eventId.Ider, format string, params ...any, ) (err error) { return nil }, AuthRequired: func( a *Operations, eid eventId.Ider, format string, params ...any, ) (err error) { return huma.Error401Unauthorized( string( reason.AuthRequired.F(format, params...), ), ) }, PoW: func( a *Operations, _ eventId.Ider, format string, params ...any, ) (err error) { return huma.Error406NotAcceptable( string( reason.PoW.F(format, params...), ), ) }, Duplicate: func( a *Operations, _ eventId.Ider, format string, params ...any, ) (err error) { return huma.Error422UnprocessableEntity( string( reason.Duplicate.F(format, params...), ), ) }, Blocked: func( a *Operations, _ eventId.Ider, format string, params ...any, ) (err error) { return huma.Error406NotAcceptable( string( reason.Blocked.F(format, params...), ), ) }, RateLimited: func( a *Operations, _ eventId.Ider, format string, params ...any, ) (err error) { return huma.Error400BadRequest( string( reason.RateLimited.F(format, params...), ), ) }, Invalid: func( a *Operations, _ eventId.Ider, format string, params ...any, ) (err error) { return huma.Error422UnprocessableEntity( string( reason.Invalid.F(format, params...), ), ) }, Error: func( a *Operations, _ eventId.Ider, format string, params ...any, ) (err error) { return huma.Error500InternalServerError( string( reason.Error.F(format, params...), ), ) }, Unsupported: func( a *Operations, _ eventId.Ider, format string, params ...any, ) (err error) { return huma.Error400BadRequest( string( reason.Unsupported.F(format, params...), ), ) }, Restricted: func( a *Operations, _ eventId.Ider, format string, params ...any, ) (err error) { return huma.Error403Forbidden( string( reason.Restricted.F(format, params...), ), ) }, }
Ok provides a collection of handler functions for managing different types of operational outcomes, each corresponding to specific error or status conditions such as authentication requirements, rate limiting, and invalid inputs.
Functions ¶
func ExposeMiddleware ¶
ExposeMiddleware adds the http.Request and http.ResponseWriter to the context for the Operations handler.
Types ¶
type EventInput ¶ added in v0.2.14
type EventInput struct {
Auth string `header:"Authorization" doc:"nostr nip-98 (and expiring variant)" required:"false"`
Accept string `header:"Accept" default:"application/nostr+json"`
Body string `doc:"event JSON"`
}
EventInput is the parameters for the Event HTTP API method.
type EventOutput ¶ added in v0.2.14
type EventOutput struct{ Body string }
EventOutput is the return parameters for the HTTP API Event method.
type ExportInput ¶ added in v0.2.11
type ExportInput struct {
Auth string `header:"Authorization" doc:"nostr nip-98 (and expiring variant)" required:"true"`
}
ExportInput is the parameters for the HTTP API Export method.
type ExportOutput ¶ added in v0.2.11
type ExportOutput struct{ RawBody []byte }
ExportOutput is the return value of Export. It usually will be line structured JSON.
type ImportInput ¶ added in v0.2.12
type ImportInput struct {
Auth string `header:"Authorization" doc:"nostr nip-98 token for authentication" required:"true"`
}
ImportInput is the parameters of an import operation, authentication and the stream of line structured JSON events.
type ImportOutput ¶ added in v0.2.12
type ImportOutput struct{}
ImportOutput is nothing, basically; a 204 or 200 status is expected.
type OK ¶ added in v0.2.14
OK represents a function that processes events or operations, using provided parameters to generate formatted messages and return errors if any issues occur during processing.
type OKs ¶ added in v0.2.14
type OKs struct {
Ok OK
AuthRequired OK
PoW OK
Duplicate OK
Blocked OK
RateLimited OK
Invalid OK
Error OK
Unsupported OK
Restricted OK
}
OKs provides a collection of handler functions for managing different types of operational outcomes, each corresponding to specific error or status conditions such as authentication requirements, rate limiting, and invalid inputs.
type Operations ¶
func (*Operations) RegisterEvent ¶ added in v0.2.14
func (x *Operations) RegisterEvent(api huma.API)
RegisterEvent is the implementation of the HTTP API Event method.
func (*Operations) RegisterExport ¶ added in v0.2.11
func (x *Operations) RegisterExport(api huma.API)
RegisterExport implements the Export HTTP API method.
func (*Operations) RegisterImport ¶ added in v0.2.12
func (x *Operations) RegisterImport(api huma.API)
RegisterImport is the implementation of the Import operation.