openapi

package
v1.14.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2025 License: Unlicense Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const Type = "openapi"

Variables

This section is empty.

Functions

func ExposeMiddleware

func ExposeMiddleware(ctx huma.Context, next func(huma.Context))

ExposeMiddleware adds the http.Request and http.ResponseWriter to the context for the Operations handler.

func NewHuma

func NewHuma(router *ServeMux, name, version, description string) (api huma.API)

NewHuma creates a new huma.API with a Scalar docs UI, and a middleware that allows methods to access the http.Request and http.ResponseWriter.

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

type ConfigurationGetOutput struct {
	Body store.Configuration `doc:"the current configuration"`
}

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 *store.Configuration `doc:"the new configuration"`
}

ConfigurationSetInput is the parameters for HTTP API method to set Configuration.

type DisconnectInput

type DisconnectInput struct {
	Auth string `header:"Authorization" doc:"nostr nip-98 (and expiring variant)" required:"true"`
}

DisconnectInput is the parameters for triggering the disconnection of all open websockets.

type DisconnectOutput

type DisconnectOutput struct{}

DisconnectOutput is the result type for the Disconnect HTTP API method.

type EventInput

type EventInput struct {
	Auth    string `header:"Authorization" doc:"nostr nip-98 (and expiring variant)" required:"false"`
	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"`
	Body []string `doc:"list of event Ids"`
}

EventsInput is the parameters for an Events HTTP API method. Basically an array of eventid.T.

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.

func (FilterInput) ToFilter

func (fi FilterInput) ToFilter() (f *filter.T, err error)

ToFilter converts a SimpleFilter input to a regular nostr filter.T.

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 added in v1.14.3

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.

func (*H) Type added in v1.14.3

func (h *H) Type() string

type ImportInput

type ImportInput struct {
	Auth    string `header:"Authorization" doc:"nostr nip-98 token for authentication" required:"true"`
	RawBody []byte
}

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 Map added in v1.14.3

type Map map[*H]struct{}

Map is a collection of H TTP subscriptions.

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 }

func NewOperations

func NewOperations(s interfaces.Server) (ep *Operations)

NewOperations creates a new openapi.Operations..

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) RegisterDisconnect

func (x *Operations) RegisterDisconnect(api huma.API)

RegisterDisconnect is the implementation of the HTTP API Disconnect method.

func (*Operations) RegisterEvent

func (x *Operations) RegisterEvent(api huma.API)

RegisterEvent is the implementatino of the HTTP API Event method.

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 added in v1.14.3

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 New added in v1.14.3

func New() *S

func (*S) Deliver added in v1.14.3

func (p *S) Deliver(authRequired, publicReadable bool, ev *event.T)

func (*S) Receive added in v1.14.3

func (p *S) Receive(msg publisher.Message)

func (*S) Type added in v1.14.3

func (p *S) Type() string

type ServeMux

type ServeMux struct {
	*http.ServeMux
}

func NewServeMux

func NewServeMux() *ServeMux

func (*ServeMux) ServeHTTP

func (c *ServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

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"`
}

func (SubscribeInput) ToFilter

func (fi SubscribeInput) ToFilter() (f *filter.T, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL