Documentation
¶
Index ¶
- Constants
- func ExposeMiddleware(ctx huma.Context, next func(huma.Context))
- func New(s interfaces.Server, name, version, description string, path string, ...)
- func NewHuma(router *servemux.S, name, version, description string) (api huma.API)
- type ConfigurationGetInput
- type ConfigurationGetOutput
- type ConfigurationSetInput
- type EventCountOutput
- type EventIdsBySerialInput
- type EventIdsBySerialOutput
- type EventIdsBySerialOutputBody
- type EventInput
- type EventOutput
- type EventsInput
- type EventsOutput
- type ExportInput
- type ExportOutput
- type FilterInput
- type FilterOutput
- type H
- type ImportInput
- type ImportOutput
- type Map
- type NukeInput
- type NukeOutput
- type Operations
- func (x *Operations) RegisterConfigurationGet(api huma.API)
- func (x *Operations) RegisterConfigurationSet(api huma.API)
- func (x *Operations) RegisterEvent(api huma.API)
- func (x *Operations) RegisterEventCount(api huma.API)
- func (x *Operations) RegisterEventIdsBySerial(api huma.API)
- func (x *Operations) RegisterEvents(api huma.API)
- func (x *Operations) RegisterExport(api huma.API)
- func (x *Operations) RegisterFilter(api huma.API)
- func (x *Operations) RegisterImport(api huma.API)
- func (x *Operations) RegisterNuke(api huma.API)
- func (x *Operations) RegisterRelay(api huma.API)
- func (x *Operations) RegisterRescan(api huma.API)
- func (x *Operations) RegisterShutdown(api huma.API)
- func (x *Operations) RegisterSubscribe(api huma.API)
- type RelayInput
- type RelayOutput
- type RescanInput
- type RescanOutput
- type S
- type ServeMux
- type ShutdownInput
- type ShutdownOutput
- type SimpleFilter
- type SubscribeInput
Constants ¶
const Type = "openapi"
Variables ¶
This section is empty.
Functions ¶
func ExposeMiddleware ¶
ExposeMiddleware adds the http.Request and http.ResponseWriter to the context for the Operations handler.
Types ¶
type ConfigurationGetInput ¶
type ConfigurationGetInput struct {
Auth string `header:"Authorization" doc:"nostr nip-98 (and expiring variant)" required:"true"`
Accept string `header:"Accept" default:"application/json" enum:"application/json" required:"true"`
}
ConfigurationGetInput is the parameters for HTTP API method to get Configuration.
type ConfigurationGetOutput ¶
ConfigurationGetOutput is the result of getting Configuration.
type ConfigurationSetInput ¶
type ConfigurationSetInput struct {
Auth string `header:"Authorization" doc:"nostr nip-98 (and expiring variant)" required:"true"`
Body config.C `doc:"the new configuration"`
Accept string `header:"Accept" default:"application/json" required:"false"`
}
ConfigurationSetInput is the parameters for HTTP API method to set Configuration.
type EventCountOutput ¶
type EventCountOutput struct{ Body uint64 }
type EventIdsBySerialInput ¶
type EventIdsBySerialOutput ¶
type EventIdsBySerialOutput struct {
Body []eventidserial.E `doc:"event serials andIDs"`
}
type EventIdsBySerialOutputBody ¶
type EventIdsBySerialOutputBody struct {
Events []eventidserial.E `doc:"event serials andIDs"`
}
type EventInput ¶
type EventInput struct {
Auth string `header:"Authorization" doc:"nostr nip-98 (and expiring variant)" required:"false"`
Accept string `header:"Accept" default:"application/nostr+json;q=0.9,application/x-realy-event:q=0.1"`
RawBody []byte
}
EventInput is the parameters for the Event HTTP API method.
type EventOutput ¶
type EventOutput struct{ Body string }
EventOutput is the return parameters for the HTTP API Event method.
type EventsInput ¶
type EventsInput struct {
Auth string `header:"Authorization" doc:"nostr nip-98 (and expiring variant)" required:"false"`
Accept string `` /* 215-byte string literal not displayed */
Body []string `doc:"list of event Ids"`
}
EventsInput is the parameters for an Events HTTP API method. Basically an array of eventid.T.
type EventsOutput ¶ added in v1.18.0
type EventsOutput struct {
Limit int `header:"X-Limit" default:"1000" doc:"informs client maximum number of events that they can request"`
}
type ExportInput ¶
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 ¶
type ExportOutput struct{ RawBody []byte }
ExportOutput is the return value of Export. It usually will be line structured JSON. In future there may be more output formats.
type FilterInput ¶
type FilterInput struct {
Auth string `header:"Authorization" doc:"nostr nip-98 (and expiring variant)" required:"false"`
Since int64 `query:"since" doc:"timestamp of the oldest events to return (inclusive)"`
Until int64 `query:"until" doc:"timestamp of the newest events to return (inclusive)"`
Limit uint `query:"limit" doc:"maximum number of results to return"`
Sort string `query:"sort" enum:"asc,desc" default:"desc" doc:"sort order by created_at timestamp"`
Body SimpleFilter `body:"filter" doc:"filter criteria to match for events to return"`
}
FilterInput is the parameters for a Filter HTTP API call.
type FilterOutput ¶
type FilterOutput struct {
Body []string `doc:"list of event Ids that mach the query in the sort order requested"`
}
FilterOutput is a list of event Ids that match the query in the sort order requested.
type H ¶
type H struct {
// Ctx is the http.Request context of the subscriber, this enables garbage
// collecting the subscriptions from http.
Ctx context.T
// Receiver is a channel that the listener sends subscription events to for http
// subscribe endpoint.
Receiver event.C
// Pubkey is the pubkey authed to this subscription
Pubkey []byte
// Filter is the filter associated with the http subscription
Filter *filter.T
}
H is the control structure for a HTTP SSE subscription, including the filter, authed pubkey and a channel to send the events to.
type ImportInput ¶
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 ¶
type ImportOutput struct{}
ImportOutput is nothing, basically, a 204 or 200 status is expected.
type NukeInput ¶
type NukeInput struct {
Auth string `header:"Authorization" doc:"nostr nip-98 (and expiring variant)" required:"true"`
Confirm string `header:"X-Confirm" doc:"must put 'Yes I Am Sure' in this field as confirmation"`
}
NukeInput is the parameters for the HTTP API method nuke. Note that it has a confirmation header that must be provided to prevent accidental invocation of this method.
type NukeOutput ¶
type NukeOutput struct{}
NukeOutput is basically nothing, a 200 or 204 HTTP status response is normal.
type Operations ¶
type Operations struct {
interfaces.Server
*servemux.S
// contains filtered or unexported fields
}
func (*Operations) RegisterConfigurationGet ¶
func (x *Operations) RegisterConfigurationGet(api huma.API)
RegisterConfigurationGet implements the HTTP API for getting the Configuration.
func (*Operations) RegisterConfigurationSet ¶
func (x *Operations) RegisterConfigurationSet(api huma.API)
RegisterConfigurationSet implements the HTTP API for setting Configuration.
func (*Operations) RegisterEvent ¶
func (x *Operations) RegisterEvent(api huma.API)
RegisterEvent is the implementatino of the HTTP API Event method.
func (*Operations) RegisterEventCount ¶
func (x *Operations) RegisterEventCount(api huma.API)
func (*Operations) RegisterEventIdsBySerial ¶
func (x *Operations) RegisterEventIdsBySerial(api huma.API)
RegisterEventIdsBySerial is a query that allows fetching of events based on their internal serial number, enabling simple synchronisation of the database of events in the order they were stored.
If the event doesn't exist, the next largest one that does is the start and the count parameter says how many.
Results are a json object with keys as stringified versions of the serial numbers, in ascending order.
Serials are guaranteed to be stable and either refer to the same event or not exist anymore if the event was deleted, and start at zero and count up monotonically, and atomically.
Requests are limited to 512 events per request, and the next number after the last result will refer to the next event in the sequence of serial numbers of events that exist.
func (*Operations) RegisterEvents ¶
func (x *Operations) RegisterEvents(api huma.API)
RegisterEvents is the implementation of the HTTP API for Events.
func (*Operations) RegisterExport ¶
func (x *Operations) RegisterExport(api huma.API)
RegisterExport implements the Export HTTP API method.
func (*Operations) RegisterFilter ¶
func (x *Operations) RegisterFilter(api huma.API)
RegisterFilter is the implementation of the HTTP API Filter method.
func (*Operations) RegisterImport ¶
func (x *Operations) RegisterImport(api huma.API)
RegisterImport is the implementation of the Import operation.
func (*Operations) RegisterNuke ¶
func (x *Operations) RegisterNuke(api huma.API)
RegisterNuke is the implementation of the Nuke HTTP API method.
func (*Operations) RegisterRelay ¶
func (x *Operations) RegisterRelay(api huma.API)
RegisterRelay is the implementatino of the HTTP API Relay method.
func (*Operations) RegisterRescan ¶
func (x *Operations) RegisterRescan(api huma.API)
func (*Operations) RegisterShutdown ¶
func (x *Operations) RegisterShutdown(api huma.API)
func (*Operations) RegisterSubscribe ¶
func (x *Operations) RegisterSubscribe(api huma.API)
type RelayInput ¶
type RelayInput struct {
Auth string `header:"Authorization" doc:"nostr nip-98 (and expiring variant)" required:"false"`
RawBody []byte
}
RelayInput is the parameters for the Event HTTP API method.
type RelayOutput ¶
type RelayOutput struct{ Body string }
RelayOutput is the return parameters for the HTTP API Relay method.
type RescanInput ¶
type RescanInput struct {
Auth string `header:"Authorization" doc:"nostr nip-98 (and expiring variant)" required:"true"`
}
type RescanOutput ¶
type RescanOutput struct{}
type S ¶
type S struct {
// Map is the map of subscriptions from the http api.
Map
// HLock is the mutex that locks the Map.
Mx sync.Mutex
}
func NewPublisher ¶
func NewPublisher() *S
type ServeMux ¶
func NewServeMux ¶
func NewServeMux() *ServeMux
type ShutdownInput ¶
type ShutdownInput struct {
Auth string `header:"Authorization" doc:"nostr nip-98 (and expiring variant)" required:"true"`
}
type ShutdownOutput ¶
type ShutdownOutput struct{}
type SimpleFilter ¶
type SimpleFilter struct {
Kinds []int `json:"kinds,omitempty" doc:"array of kind numbers to match on"`
Authors []string `json:"authors,omitempty" doc:"array of author pubkeys to match on (hex encoded)"`
Tags [][]string `` /* 136-byte string literal not displayed */
}
SimpleFilter is the main parts of a filter.T that relate to event store indexes.
type SubscribeInput ¶
type SubscribeInput struct {
Auth string `header:"Authorization" doc:"nostr nip-98 (and expiring variant)" required:"false"`
Accept string `header:"Accept" default:"text/event-stream" enum:"text/event-stream" required:"true"`
// ContentType string `header:"Content-Type" default:"text/event-stream" enum:"text/event-stream" required:"true"`
Body SimpleFilter `body:"filter" doc:"filter criteria to match for events to return"`
}