api

package
v1.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Code generated by ogen, DO NOT EDIT.

Index

Constants

View Source
const (
	MediaTypeApplicationJSON string = "application/json"
	MediaTypeTextEventStream string = "text/event-stream"
)

Variables

This section is empty.

Functions

func WithServerURL

func WithServerURL(ctx context.Context, u *url.URL) context.Context

WithServerURL sets context key to override server URL.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements OAS client.

func NewClient

func NewClient(serverURL string, opts ...ClientOption) (*Client, error)

NewClient initializes new Client defined by OAS.

func (*Client) DataOnly

func (c *Client) DataOnly(ctx context.Context) (*DataOnlyOK, error)

DataOnly invokes dataOnly operation.

GET /data-only

func (*Client) DataOnlyString

func (c *Client) DataOnlyString(ctx context.Context) (*DataOnlyStringOK, error)

DataOnlyString invokes dataOnlyString operation.

GET /data-only-string

func (*Client) DataOnlyTime

func (c *Client) DataOnlyTime(ctx context.Context) (*DataOnlyTimeOK, error)

DataOnlyTime invokes dataOnlyTime operation.

GET /data-only-time

func (*Client) FullEvents

func (c *Client) FullEvents(ctx context.Context) (*FullEventsOK, error)

FullEvents invokes fullEvents operation.

GET /full

func (*Client) OptionalStream

func (c *Client) OptionalStream(ctx context.Context, params OptionalStreamParams) (OptionalStreamRes, error)

OptionalStream invokes optionalStream operation.

GET /optional-stream

func (*Client) WithHeaders

func (c *Client) WithHeaders(ctx context.Context) (*WithHeadersOKHeaders, error)

WithHeaders invokes withHeaders operation.

GET /with-headers

type ClientOption

type ClientOption interface {
	// contains filtered or unexported methods
}

ClientOption is client config option.

func WithClient

func WithClient(client ht.Client) ClientOption

WithClient specifies http client to use.

func WithSSEClientOptions

func WithSSEClientOptions(opts ...SSEClientOption) ClientOption

WithSSEClientOptions configures default SSE client behavior.

type DataOnlyOK

type DataOnlyOK struct {
	// Events writes the stream events.
	//
	// It is called by the generated server after the response headers are
	// sent, until it returns. A nil Events sends an empty stream.
	//
	// Events is not used by the generated client.
	Events func(ctx context.Context, s DataOnlyOKSender) error
	// KeepAlive keeps an idle connection open while Events runs. It is called
	// concurrently with Events and shares the same sender, which is safe for
	// concurrent use. It should return when its context is canceled, which
	// happens once Events returns.
	//
	// If nil, a "keep-alive" comment is sent every [sse.DefaultKeepAliveInterval].
	// Set it to a function that returns immediately to disable keep-alive.
	//
	// KeepAlive is not used by the generated client.
	KeepAlive func(ctx context.Context, s DataOnlyOKSender) error
	// contains filtered or unexported fields
}

DataOnlyOK is a Server-Sent Events response stream.

func (*DataOnlyOK) All

All iterates over stream events until the stream is closed, reconnecting when needed.

func (*DataOnlyOK) Close

func (s *DataOnlyOK) Close() error

Close closes the current stream and stops further reconnect attempts.

func (*DataOnlyOK) Next

func (s *DataOnlyOK) Next(ctx context.Context,
) (DataOnlyOKEvent, error)

Next returns the next event from the stream, reconnecting when needed.

func (*DataOnlyOK) State

func (s *DataOnlyOK) State() (state sse.State, latestErr error)

State returns the current stream state and the latest terminal or current reconnect error.

type DataOnlyOKClient

type DataOnlyOKClient interface {
	sse.Client[DataOnlyOKEvent]
}

DataOnlyOKClient reads events from the DataOnlyOK SSE stream.

type DataOnlyOKEvent

type DataOnlyOKEvent struct {
	ID    string  `json:"id"`
	Type  string  `json:"event"`
	Data  Message `json:"data"`
	Retry OptInt  `json:"retry"`
}

DataOnlyOKEvent is a parsed Server-Sent Event.

func (*DataOnlyOKEvent) GetData

func (s *DataOnlyOKEvent) GetData() Message

GetData returns the value of Data.

func (*DataOnlyOKEvent) GetID

func (s *DataOnlyOKEvent) GetID() string

GetID returns the value of ID.

func (*DataOnlyOKEvent) GetRetry

func (s *DataOnlyOKEvent) GetRetry() OptInt

GetRetry returns the value of Retry.

func (*DataOnlyOKEvent) GetType

func (s *DataOnlyOKEvent) GetType() string

GetType returns the value of Type.

func (*DataOnlyOKEvent) SetData

func (s *DataOnlyOKEvent) SetData(val Message)

SetData sets the value of Data.

func (*DataOnlyOKEvent) SetID

func (s *DataOnlyOKEvent) SetID(val string)

SetID sets the value of ID.

func (*DataOnlyOKEvent) SetRetry

func (s *DataOnlyOKEvent) SetRetry(val OptInt)

SetRetry sets the value of Retry.

func (*DataOnlyOKEvent) SetType

func (s *DataOnlyOKEvent) SetType(val string)

SetType sets the value of Type.

func (*DataOnlyOKEvent) Validate

func (s *DataOnlyOKEvent) Validate() error

type DataOnlyOKSender

type DataOnlyOKSender interface {
	sse.Sender[DataOnlyOKEvent]
}

DataOnlyOKSender sends events to the DataOnlyOK SSE stream.

type DataOnlyStringOK

type DataOnlyStringOK struct {
	// Events writes the stream events.
	//
	// It is called by the generated server after the response headers are
	// sent, until it returns. A nil Events sends an empty stream.
	//
	// Events is not used by the generated client.
	Events func(ctx context.Context, s DataOnlyStringOKSender) error
	// KeepAlive keeps an idle connection open while Events runs. It is called
	// concurrently with Events and shares the same sender, which is safe for
	// concurrent use. It should return when its context is canceled, which
	// happens once Events returns.
	//
	// If nil, a "keep-alive" comment is sent every [sse.DefaultKeepAliveInterval].
	// Set it to a function that returns immediately to disable keep-alive.
	//
	// KeepAlive is not used by the generated client.
	KeepAlive func(ctx context.Context, s DataOnlyStringOKSender) error
	// contains filtered or unexported fields
}

DataOnlyStringOK is a Server-Sent Events response stream.

func (*DataOnlyStringOK) All

All iterates over stream events until the stream is closed, reconnecting when needed.

func (*DataOnlyStringOK) Close

func (s *DataOnlyStringOK) Close() error

Close closes the current stream and stops further reconnect attempts.

func (*DataOnlyStringOK) Next

Next returns the next event from the stream, reconnecting when needed.

func (*DataOnlyStringOK) State

func (s *DataOnlyStringOK) State() (state sse.State, latestErr error)

State returns the current stream state and the latest terminal or current reconnect error.

type DataOnlyStringOKClient

type DataOnlyStringOKClient interface {
	sse.Client[DataOnlyStringOKEvent]
}

DataOnlyStringOKClient reads events from the DataOnlyStringOK SSE stream.

type DataOnlyStringOKEvent

type DataOnlyStringOKEvent struct {
	ID    string `json:"id"`
	Type  string `json:"event"`
	Data  string `json:"data"`
	Retry OptInt `json:"retry"`
}

DataOnlyStringOKEvent is a parsed Server-Sent Event.

func (*DataOnlyStringOKEvent) GetData

func (s *DataOnlyStringOKEvent) GetData() string

GetData returns the value of Data.

func (*DataOnlyStringOKEvent) GetID

func (s *DataOnlyStringOKEvent) GetID() string

GetID returns the value of ID.

func (*DataOnlyStringOKEvent) GetRetry

func (s *DataOnlyStringOKEvent) GetRetry() OptInt

GetRetry returns the value of Retry.

func (*DataOnlyStringOKEvent) GetType

func (s *DataOnlyStringOKEvent) GetType() string

GetType returns the value of Type.

func (*DataOnlyStringOKEvent) SetData

func (s *DataOnlyStringOKEvent) SetData(val string)

SetData sets the value of Data.

func (*DataOnlyStringOKEvent) SetID

func (s *DataOnlyStringOKEvent) SetID(val string)

SetID sets the value of ID.

func (*DataOnlyStringOKEvent) SetRetry

func (s *DataOnlyStringOKEvent) SetRetry(val OptInt)

SetRetry sets the value of Retry.

func (*DataOnlyStringOKEvent) SetType

func (s *DataOnlyStringOKEvent) SetType(val string)

SetType sets the value of Type.

type DataOnlyStringOKSender

type DataOnlyStringOKSender interface {
	sse.Sender[DataOnlyStringOKEvent]
}

DataOnlyStringOKSender sends events to the DataOnlyStringOK SSE stream.

type DataOnlyTimeOK

type DataOnlyTimeOK struct {
	// Events writes the stream events.
	//
	// It is called by the generated server after the response headers are
	// sent, until it returns. A nil Events sends an empty stream.
	//
	// Events is not used by the generated client.
	Events func(ctx context.Context, s DataOnlyTimeOKSender) error
	// KeepAlive keeps an idle connection open while Events runs. It is called
	// concurrently with Events and shares the same sender, which is safe for
	// concurrent use. It should return when its context is canceled, which
	// happens once Events returns.
	//
	// If nil, a "keep-alive" comment is sent every [sse.DefaultKeepAliveInterval].
	// Set it to a function that returns immediately to disable keep-alive.
	//
	// KeepAlive is not used by the generated client.
	KeepAlive func(ctx context.Context, s DataOnlyTimeOKSender) error
	// contains filtered or unexported fields
}

DataOnlyTimeOK is a Server-Sent Events response stream.

func (*DataOnlyTimeOK) All

All iterates over stream events until the stream is closed, reconnecting when needed.

func (*DataOnlyTimeOK) Close

func (s *DataOnlyTimeOK) Close() error

Close closes the current stream and stops further reconnect attempts.

func (*DataOnlyTimeOK) Next

Next returns the next event from the stream, reconnecting when needed.

func (*DataOnlyTimeOK) State

func (s *DataOnlyTimeOK) State() (state sse.State, latestErr error)

State returns the current stream state and the latest terminal or current reconnect error.

type DataOnlyTimeOKClient

type DataOnlyTimeOKClient interface {
	sse.Client[DataOnlyTimeOKEvent]
}

DataOnlyTimeOKClient reads events from the DataOnlyTimeOK SSE stream.

type DataOnlyTimeOKEvent

type DataOnlyTimeOKEvent struct {
	ID    string    `json:"id"`
	Type  string    `json:"event"`
	Data  time.Time `json:"data"`
	Retry OptInt    `json:"retry"`
}

DataOnlyTimeOKEvent is a parsed Server-Sent Event.

func (*DataOnlyTimeOKEvent) GetData

func (s *DataOnlyTimeOKEvent) GetData() time.Time

GetData returns the value of Data.

func (*DataOnlyTimeOKEvent) GetID

func (s *DataOnlyTimeOKEvent) GetID() string

GetID returns the value of ID.

func (*DataOnlyTimeOKEvent) GetRetry

func (s *DataOnlyTimeOKEvent) GetRetry() OptInt

GetRetry returns the value of Retry.

func (*DataOnlyTimeOKEvent) GetType

func (s *DataOnlyTimeOKEvent) GetType() string

GetType returns the value of Type.

func (*DataOnlyTimeOKEvent) SetData

func (s *DataOnlyTimeOKEvent) SetData(val time.Time)

SetData sets the value of Data.

func (*DataOnlyTimeOKEvent) SetID

func (s *DataOnlyTimeOKEvent) SetID(val string)

SetID sets the value of ID.

func (*DataOnlyTimeOKEvent) SetRetry

func (s *DataOnlyTimeOKEvent) SetRetry(val OptInt)

SetRetry sets the value of Retry.

func (*DataOnlyTimeOKEvent) SetType

func (s *DataOnlyTimeOKEvent) SetType(val string)

SetType sets the value of Type.

type DataOnlyTimeOKSender

type DataOnlyTimeOKSender interface {
	sse.Sender[DataOnlyTimeOKEvent]
}

DataOnlyTimeOKSender sends events to the DataOnlyTimeOK SSE stream.

type Error

type Error struct {
	Message string `json:"message"`
}

Ref: #/components/schemas/Error

func (*Error) Decode

func (s *Error) Decode(d *jx.Decoder) error

Decode decodes Error from json.

func (*Error) Encode

func (s *Error) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*Error) GetMessage

func (s *Error) GetMessage() string

GetMessage returns the value of Message.

func (*Error) MarshalJSON

func (s *Error) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*Error) SetMessage

func (s *Error) SetMessage(val string)

SetMessage sets the value of Message.

func (*Error) UnmarshalJSON

func (s *Error) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type ErrorHandler

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type EventA

type EventA struct {
	Event EventAEvent `json:"event"`
	Data  Message     `json:"data"`
	ID    string      `json:"id"`
	Retry OptInt      `json:"retry"`
}

Ref: #/components/schemas/EventA

func (*EventA) Decode

func (s *EventA) Decode(d *jx.Decoder) error

Decode decodes EventA from json.

func (*EventA) Encode

func (s *EventA) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*EventA) GetData

func (s *EventA) GetData() Message

GetData returns the value of Data.

func (*EventA) GetEvent

func (s *EventA) GetEvent() EventAEvent

GetEvent returns the value of Event.

func (*EventA) GetID

func (s *EventA) GetID() string

GetID returns the value of ID.

func (*EventA) GetRetry

func (s *EventA) GetRetry() OptInt

GetRetry returns the value of Retry.

func (*EventA) MarshalJSON

func (s *EventA) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*EventA) SetData

func (s *EventA) SetData(val Message)

SetData sets the value of Data.

func (*EventA) SetEvent

func (s *EventA) SetEvent(val EventAEvent)

SetEvent sets the value of Event.

func (*EventA) SetID

func (s *EventA) SetID(val string)

SetID sets the value of ID.

func (*EventA) SetRetry

func (s *EventA) SetRetry(val OptInt)

SetRetry sets the value of Retry.

func (*EventA) UnmarshalJSON

func (s *EventA) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*EventA) Validate

func (s *EventA) Validate() error

type EventAEvent

type EventAEvent string
const (
	EventAEventEventA EventAEvent = "event_a"
)

func (EventAEvent) AllValues

func (EventAEvent) AllValues() []EventAEvent

AllValues returns all EventAEvent values.

func (*EventAEvent) Decode

func (s *EventAEvent) Decode(d *jx.Decoder) error

Decode decodes EventAEvent from json.

func (EventAEvent) Encode

func (s EventAEvent) Encode(e *jx.Encoder)

Encode encodes EventAEvent as json.

func (EventAEvent) MarshalJSON

func (s EventAEvent) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (EventAEvent) MarshalText

func (s EventAEvent) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*EventAEvent) UnmarshalJSON

func (s *EventAEvent) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*EventAEvent) UnmarshalText

func (s *EventAEvent) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (EventAEvent) Validate

func (s EventAEvent) Validate() error

type EventB

type EventB struct {
	Event EventBEvent `json:"event"`
	ID    string      `json:"id"`
	Data  string      `json:"data"`
	Retry OptInt      `json:"retry"`
}

Ref: #/components/schemas/EventB

func (*EventB) Decode

func (s *EventB) Decode(d *jx.Decoder) error

Decode decodes EventB from json.

func (*EventB) Encode

func (s *EventB) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*EventB) GetData

func (s *EventB) GetData() string

GetData returns the value of Data.

func (*EventB) GetEvent

func (s *EventB) GetEvent() EventBEvent

GetEvent returns the value of Event.

func (*EventB) GetID

func (s *EventB) GetID() string

GetID returns the value of ID.

func (*EventB) GetRetry

func (s *EventB) GetRetry() OptInt

GetRetry returns the value of Retry.

func (*EventB) MarshalJSON

func (s *EventB) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*EventB) SetData

func (s *EventB) SetData(val string)

SetData sets the value of Data.

func (*EventB) SetEvent

func (s *EventB) SetEvent(val EventBEvent)

SetEvent sets the value of Event.

func (*EventB) SetID

func (s *EventB) SetID(val string)

SetID sets the value of ID.

func (*EventB) SetRetry

func (s *EventB) SetRetry(val OptInt)

SetRetry sets the value of Retry.

func (*EventB) UnmarshalJSON

func (s *EventB) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*EventB) Validate

func (s *EventB) Validate() error

type EventBEvent

type EventBEvent string
const (
	EventBEventEventB EventBEvent = "event_b"
)

func (EventBEvent) AllValues

func (EventBEvent) AllValues() []EventBEvent

AllValues returns all EventBEvent values.

func (*EventBEvent) Decode

func (s *EventBEvent) Decode(d *jx.Decoder) error

Decode decodes EventBEvent from json.

func (EventBEvent) Encode

func (s EventBEvent) Encode(e *jx.Encoder)

Encode encodes EventBEvent as json.

func (EventBEvent) MarshalJSON

func (s EventBEvent) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (EventBEvent) MarshalText

func (s EventBEvent) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*EventBEvent) UnmarshalJSON

func (s *EventBEvent) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*EventBEvent) UnmarshalText

func (s *EventBEvent) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (EventBEvent) Validate

func (s EventBEvent) Validate() error

type FullEventsOK

type FullEventsOK struct {
	// Events writes the stream events.
	//
	// It is called by the generated server after the response headers are
	// sent, until it returns. A nil Events sends an empty stream.
	//
	// Events is not used by the generated client.
	Events func(ctx context.Context, s FullEventsOKSender) error
	// KeepAlive keeps an idle connection open while Events runs. It is called
	// concurrently with Events and shares the same sender, which is safe for
	// concurrent use. It should return when its context is canceled, which
	// happens once Events returns.
	//
	// If nil, a "keep-alive" comment is sent every [sse.DefaultKeepAliveInterval].
	// Set it to a function that returns immediately to disable keep-alive.
	//
	// KeepAlive is not used by the generated client.
	KeepAlive func(ctx context.Context, s FullEventsOKSender) error
	// contains filtered or unexported fields
}

FullEventsOK is a Server-Sent Events response stream.

func (*FullEventsOK) All

All iterates over stream events until the stream is closed, reconnecting when needed.

func (*FullEventsOK) Close

func (s *FullEventsOK) Close() error

Close closes the current stream and stops further reconnect attempts.

func (*FullEventsOK) Next

Next returns the next event from the stream, reconnecting when needed.

func (*FullEventsOK) State

func (s *FullEventsOK) State() (state sse.State, latestErr error)

State returns the current stream state and the latest terminal or current reconnect error.

type FullEventsOKClient

type FullEventsOKClient interface {
	sse.Client[FullEventsOKEvent]
}

FullEventsOKClient reads events from the FullEventsOK SSE stream.

type FullEventsOKEvent

type FullEventsOKEvent struct {
	// Type selects the active sum variant, switch on this field.
	Type   FullEventsOKEventType
	EventA EventA
	EventB EventB
}

FullEventsOKEvent represents sum type.

func NewEventAFullEventsOKEvent

func NewEventAFullEventsOKEvent(v EventA) FullEventsOKEvent

NewEventAFullEventsOKEvent returns new FullEventsOKEvent from EventA.

func NewEventBFullEventsOKEvent

func NewEventBFullEventsOKEvent(v EventB) FullEventsOKEvent

NewEventBFullEventsOKEvent returns new FullEventsOKEvent from EventB.

func (*FullEventsOKEvent) Decode

func (s *FullEventsOKEvent) Decode(d *jx.Decoder) error

Decode decodes FullEventsOKEvent from json.

func (FullEventsOKEvent) Encode

func (s FullEventsOKEvent) Encode(e *jx.Encoder)

Encode encodes FullEventsOKEvent as json.

func (FullEventsOKEvent) GetEventA

func (s FullEventsOKEvent) GetEventA() (v EventA, ok bool)

GetEventA returns EventA and true boolean if FullEventsOKEvent is EventA.

func (FullEventsOKEvent) GetEventB

func (s FullEventsOKEvent) GetEventB() (v EventB, ok bool)

GetEventB returns EventB and true boolean if FullEventsOKEvent is EventB.

func (FullEventsOKEvent) IsEventA

func (s FullEventsOKEvent) IsEventA() bool

IsEventA reports whether FullEventsOKEvent is EventA.

func (FullEventsOKEvent) IsEventB

func (s FullEventsOKEvent) IsEventB() bool

IsEventB reports whether FullEventsOKEvent is EventB.

func (FullEventsOKEvent) MarshalJSON

func (s FullEventsOKEvent) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*FullEventsOKEvent) SetEventA

func (s *FullEventsOKEvent) SetEventA(v EventA)

SetEventA sets FullEventsOKEvent to EventA.

func (*FullEventsOKEvent) SetEventB

func (s *FullEventsOKEvent) SetEventB(v EventB)

SetEventB sets FullEventsOKEvent to EventB.

func (*FullEventsOKEvent) UnmarshalJSON

func (s *FullEventsOKEvent) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (FullEventsOKEvent) Validate

func (s FullEventsOKEvent) Validate() error

type FullEventsOKEventType

type FullEventsOKEventType string

FullEventsOKEventType is oneOf type of FullEventsOKEvent.

const (
	EventAFullEventsOKEvent FullEventsOKEventType = "event_a"
	EventBFullEventsOKEvent FullEventsOKEventType = "event_b"
)

Possible values for FullEventsOKEventType.

type FullEventsOKSender

type FullEventsOKSender interface {
	sse.Sender[FullEventsOKEvent]
}

FullEventsOKSender sends events to the FullEventsOK SSE stream.

type Handler

type Handler interface {
	// DataOnly implements dataOnly operation.
	//
	// GET /data-only
	DataOnly(ctx context.Context) (*DataOnlyOK, error)
	// DataOnlyString implements dataOnlyString operation.
	//
	// GET /data-only-string
	DataOnlyString(ctx context.Context) (*DataOnlyStringOK, error)
	// DataOnlyTime implements dataOnlyTime operation.
	//
	// GET /data-only-time
	DataOnlyTime(ctx context.Context) (*DataOnlyTimeOK, error)
	// FullEvents implements fullEvents operation.
	//
	// GET /full
	FullEvents(ctx context.Context) (*FullEventsOK, error)
	// OptionalStream implements optionalStream operation.
	//
	// GET /optional-stream
	OptionalStream(ctx context.Context, params OptionalStreamParams) (OptionalStreamRes, error)
	// WithHeaders implements withHeaders operation.
	//
	// GET /with-headers
	WithHeaders(ctx context.Context) (*WithHeadersOKHeaders, error)
}

Handler handles operations described by OpenAPI v3 specification.

type Invoker

type Invoker interface {
	// DataOnly invokes dataOnly operation.
	//
	// GET /data-only
	DataOnly(ctx context.Context) (*DataOnlyOK, error)
	// DataOnlyString invokes dataOnlyString operation.
	//
	// GET /data-only-string
	DataOnlyString(ctx context.Context) (*DataOnlyStringOK, error)
	// DataOnlyTime invokes dataOnlyTime operation.
	//
	// GET /data-only-time
	DataOnlyTime(ctx context.Context) (*DataOnlyTimeOK, error)
	// FullEvents invokes fullEvents operation.
	//
	// GET /full
	FullEvents(ctx context.Context) (*FullEventsOK, error)
	// OptionalStream invokes optionalStream operation.
	//
	// GET /optional-stream
	OptionalStream(ctx context.Context, params OptionalStreamParams) (OptionalStreamRes, error)
	// WithHeaders invokes withHeaders operation.
	//
	// GET /with-headers
	WithHeaders(ctx context.Context) (*WithHeadersOKHeaders, error)
}

Invoker invokes operations described by OpenAPI v3 specification.

type Labeler

type Labeler struct {
	// contains filtered or unexported fields
}

Labeler is used to allow adding custom attributes to the server request metrics.

func LabelerFromContext

func LabelerFromContext(ctx context.Context) (*Labeler, bool)

LabelerFromContext retrieves the Labeler from the provided context, if present.

If no Labeler was found in the provided context a new, empty Labeler is returned and the second return value is false. In this case it is safe to use the Labeler but any attributes added to it will not be used.

func (*Labeler) Add

func (l *Labeler) Add(attrs ...attribute.KeyValue)

Add attributes to the Labeler.

func (*Labeler) AttributeSet

func (l *Labeler) AttributeSet() attribute.Set

AttributeSet returns the attributes added to the Labeler as an attribute.Set.

type Message

type Message struct {
	Text  string `json:"text"`
	Count OptInt `json:"count"`
}

Ref: #/components/schemas/Message

func (*Message) Decode

func (s *Message) Decode(d *jx.Decoder) error

Decode decodes Message from json.

func (*Message) Encode

func (s *Message) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*Message) GetCount

func (s *Message) GetCount() OptInt

GetCount returns the value of Count.

func (*Message) GetText

func (s *Message) GetText() string

GetText returns the value of Text.

func (*Message) MarshalJSON

func (s *Message) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*Message) SetCount

func (s *Message) SetCount(val OptInt)

SetCount sets the value of Count.

func (*Message) SetText

func (s *Message) SetText(val string)

SetText sets the value of Text.

func (*Message) UnmarshalJSON

func (s *Message) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*Message) Validate

func (s *Message) Validate() error

type Middleware

type Middleware = middleware.Middleware

Middleware is middleware type.

type OperationName

type OperationName = string

OperationName is the ogen operation name

const (
	DataOnlyOperation       OperationName = "DataOnly"
	DataOnlyStringOperation OperationName = "DataOnlyString"
	DataOnlyTimeOperation   OperationName = "DataOnlyTime"
	FullEventsOperation     OperationName = "FullEvents"
	OptionalStreamOperation OperationName = "OptionalStream"
	WithHeadersOperation    OperationName = "WithHeaders"
)

type OptBool

type OptBool struct {
	Value bool
	Set   bool
}

OptBool is optional bool.

func NewOptBool

func NewOptBool(v bool) OptBool

NewOptBool returns new OptBool with value set to v.

func (OptBool) Get

func (o OptBool) Get() (v bool, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptBool) IsSet

func (o OptBool) IsSet() bool

IsSet returns true if OptBool was set.

func (OptBool) Or

func (o OptBool) Or(d bool) bool

Or returns value if set, or given parameter if does not.

func (*OptBool) Reset

func (o *OptBool) Reset()

Reset unsets value.

func (*OptBool) SetTo

func (o *OptBool) SetTo(v bool)

SetTo sets value to v.

type OptInt

type OptInt struct {
	Value int
	Set   bool
}

OptInt is optional int.

func NewOptInt

func NewOptInt(v int) OptInt

NewOptInt returns new OptInt with value set to v.

func (*OptInt) Decode

func (o *OptInt) Decode(d *jx.Decoder) error

Decode decodes int from json.

func (OptInt) Encode

func (o OptInt) Encode(e *jx.Encoder)

Encode encodes int as json.

func (OptInt) Get

func (o OptInt) Get() (v int, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptInt) IsSet

func (o OptInt) IsSet() bool

IsSet returns true if OptInt was set.

func (OptInt) MarshalJSON

func (s OptInt) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptInt) Or

func (o OptInt) Or(d int) int

Or returns value if set, or given parameter if does not.

func (*OptInt) Reset

func (o *OptInt) Reset()

Reset unsets value.

func (*OptInt) SetTo

func (o *OptInt) SetTo(v int)

SetTo sets value to v.

func (*OptInt) UnmarshalJSON

func (s *OptInt) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type Option

type Option interface {
	ServerOption
	ClientOption
}

Option is config option.

func WithAttributes

func WithAttributes(attributes ...attribute.KeyValue) Option

WithAttributes specifies default otel attributes.

func WithMeterProvider

func WithMeterProvider(provider metric.MeterProvider) Option

WithMeterProvider specifies a meter provider to use for creating a meter.

If none is specified, the otel.GetMeterProvider() is used.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) Option

WithTracerProvider specifies a tracer provider to use for creating a tracer.

If none is specified, the global provider is used.

type OptionalStreamOK

type OptionalStreamOK struct {
	// Events writes the stream events.
	//
	// It is called by the generated server after the response headers are
	// sent, until it returns. A nil Events sends an empty stream.
	//
	// Events is not used by the generated client.
	Events func(ctx context.Context, s OptionalStreamOKSender) error
	// KeepAlive keeps an idle connection open while Events runs. It is called
	// concurrently with Events and shares the same sender, which is safe for
	// concurrent use. It should return when its context is canceled, which
	// happens once Events returns.
	//
	// If nil, a "keep-alive" comment is sent every [sse.DefaultKeepAliveInterval].
	// Set it to a function that returns immediately to disable keep-alive.
	//
	// KeepAlive is not used by the generated client.
	KeepAlive func(ctx context.Context, s OptionalStreamOKSender) error
	// contains filtered or unexported fields
}

OptionalStreamOK is a Server-Sent Events response stream.

func (*OptionalStreamOK) All

All iterates over stream events until the stream is closed, reconnecting when needed.

func (*OptionalStreamOK) Close

func (s *OptionalStreamOK) Close() error

Close closes the current stream and stops further reconnect attempts.

func (*OptionalStreamOK) Next

Next returns the next event from the stream, reconnecting when needed.

func (*OptionalStreamOK) State

func (s *OptionalStreamOK) State() (state sse.State, latestErr error)

State returns the current stream state and the latest terminal or current reconnect error.

type OptionalStreamOKClient

type OptionalStreamOKClient interface {
	sse.Client[OptionalStreamOKEvent]
}

OptionalStreamOKClient reads events from the OptionalStreamOK SSE stream.

type OptionalStreamOKEvent

type OptionalStreamOKEvent struct {
	ID    string  `json:"id"`
	Type  string  `json:"event"`
	Data  Message `json:"data"`
	Retry OptInt  `json:"retry"`
}

OptionalStreamOKEvent is a parsed Server-Sent Event.

func (*OptionalStreamOKEvent) GetData

func (s *OptionalStreamOKEvent) GetData() Message

GetData returns the value of Data.

func (*OptionalStreamOKEvent) GetID

func (s *OptionalStreamOKEvent) GetID() string

GetID returns the value of ID.

func (*OptionalStreamOKEvent) GetRetry

func (s *OptionalStreamOKEvent) GetRetry() OptInt

GetRetry returns the value of Retry.

func (*OptionalStreamOKEvent) GetType

func (s *OptionalStreamOKEvent) GetType() string

GetType returns the value of Type.

func (*OptionalStreamOKEvent) SetData

func (s *OptionalStreamOKEvent) SetData(val Message)

SetData sets the value of Data.

func (*OptionalStreamOKEvent) SetID

func (s *OptionalStreamOKEvent) SetID(val string)

SetID sets the value of ID.

func (*OptionalStreamOKEvent) SetRetry

func (s *OptionalStreamOKEvent) SetRetry(val OptInt)

SetRetry sets the value of Retry.

func (*OptionalStreamOKEvent) SetType

func (s *OptionalStreamOKEvent) SetType(val string)

SetType sets the value of Type.

func (*OptionalStreamOKEvent) Validate

func (s *OptionalStreamOKEvent) Validate() error

type OptionalStreamOKSender

type OptionalStreamOKSender interface {
	sse.Sender[OptionalStreamOKEvent]
}

OptionalStreamOKSender sends events to the OptionalStreamOK SSE stream.

type OptionalStreamParams

type OptionalStreamParams struct {
	Fail OptBool `json:",omitempty,omitzero"`
}

OptionalStreamParams is parameters of optionalStream operation.

type OptionalStreamRes

type OptionalStreamRes interface {
	// contains filtered or unexported methods
}

type Route

type Route struct {
	// contains filtered or unexported fields
}

Route is route object.

func (Route) Args

func (r Route) Args() []string

Args returns parsed arguments.

func (Route) Name

func (r Route) Name() string

Name returns ogen operation name.

It is guaranteed to be unique and not empty.

func (Route) OperationGroup

func (r Route) OperationGroup() string

OperationGroup returns the x-ogen-operation-group value.

func (Route) OperationID

func (r Route) OperationID() string

OperationID returns OpenAPI operationId.

func (Route) PathPattern

func (r Route) PathPattern() string

PathPattern returns OpenAPI path.

func (Route) Summary

func (r Route) Summary() string

Summary returns OpenAPI summary.

type SSEClientOption

type SSEClientOption func(*sseClientConfig)

func WithSSEInitialBufferCap

func WithSSEInitialBufferCap(n int) SSEClientOption

WithSSEInitialBufferCap sets the initial decoder line buffer capacity.

func WithSSELastEventID

func WithSSELastEventID(lastEventID string) SSEClientOption

WithSSELastEventID sets the initial lastEventID value for the stream.

func WithSSEMaxEventSize

func WithSSEMaxEventSize(n int) SSEClientOption

WithSSEMaxEventSize sets the maximum parsable SSE event size in bytes.

Zero disables the limit.

func WithSSEMaxRetries

func WithSSEMaxRetries(n int) SSEClientOption

WithSSEMaxRetries sets the maximum number of reconnect attempts.

Zero sets unlimited reconnect attempts.

func WithSSERetry

func WithSSERetry(delay time.Duration) SSEClientOption

WithSSERetry sets the initial SSE reconnect delay.

func WithSSERetryErrorHandler

func WithSSERetryErrorHandler(h sse.RetryErrorHandler) SSEClientOption

WithSSERetryErrorHandler sets the callback invoked after a reconnect attempt fails.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server implements http server based on OpenAPI v3 specification and calls Handler to handle requests.

func NewServer

func NewServer(h Handler, opts ...ServerOption) (*Server, error)

NewServer creates new Server.

func (*Server) FindPath

func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool)

FindPath finds Route for given method and URL.

func (*Server) FindRoute

func (s *Server) FindRoute(method, path string) (Route, bool)

FindRoute finds Route for given method and path.

Note: this method does not unescape path or handle reserved characters in path properly. Use FindPath instead.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves http request as defined by OpenAPI v3 specification, calling handler that matches the path or returning not found error.

type ServerOption

type ServerOption interface {
	// contains filtered or unexported methods
}

ServerOption is server config option.

func WithErrorHandler

func WithErrorHandler(h ErrorHandler) ServerOption

WithErrorHandler specifies error handler to use.

func WithMaxMultipartMemory

func WithMaxMultipartMemory(max int64) ServerOption

WithMaxMultipartMemory specifies limit of memory for storing file parts. File parts which can't be stored in memory will be stored on disk in temporary files.

func WithMethodNotAllowed

func WithMethodNotAllowed(methodNotAllowed func(w http.ResponseWriter, r *http.Request, allowed string)) ServerOption

WithMethodNotAllowed specifies Method Not Allowed handler to use.

func WithMiddleware

func WithMiddleware(m ...Middleware) ServerOption

WithMiddleware specifies middlewares to use.

func WithNotFound

func WithNotFound(notFound http.HandlerFunc) ServerOption

WithNotFound specifies Not Found handler to use.

func WithPathPrefix

func WithPathPrefix(prefix string) ServerOption

WithPathPrefix specifies server path prefix.

type UnimplementedHandler

type UnimplementedHandler struct{}

UnimplementedHandler is no-op Handler which returns http.ErrNotImplemented.

func (UnimplementedHandler) DataOnly

func (UnimplementedHandler) DataOnly(ctx context.Context) (r *DataOnlyOK, _ error)

DataOnly implements dataOnly operation.

GET /data-only

func (UnimplementedHandler) DataOnlyString

func (UnimplementedHandler) DataOnlyString(ctx context.Context) (r *DataOnlyStringOK, _ error)

DataOnlyString implements dataOnlyString operation.

GET /data-only-string

func (UnimplementedHandler) DataOnlyTime

func (UnimplementedHandler) DataOnlyTime(ctx context.Context) (r *DataOnlyTimeOK, _ error)

DataOnlyTime implements dataOnlyTime operation.

GET /data-only-time

func (UnimplementedHandler) FullEvents

func (UnimplementedHandler) FullEvents(ctx context.Context) (r *FullEventsOK, _ error)

FullEvents implements fullEvents operation.

GET /full

func (UnimplementedHandler) OptionalStream

OptionalStream implements optionalStream operation.

GET /optional-stream

func (UnimplementedHandler) WithHeaders

WithHeaders implements withHeaders operation.

GET /with-headers

type WithHeadersOK

type WithHeadersOK struct {
	// Events writes the stream events.
	//
	// It is called by the generated server after the response headers are
	// sent, until it returns. A nil Events sends an empty stream.
	//
	// Events is not used by the generated client.
	Events func(ctx context.Context, s WithHeadersOKSender) error
	// KeepAlive keeps an idle connection open while Events runs. It is called
	// concurrently with Events and shares the same sender, which is safe for
	// concurrent use. It should return when its context is canceled, which
	// happens once Events returns.
	//
	// If nil, a "keep-alive" comment is sent every [sse.DefaultKeepAliveInterval].
	// Set it to a function that returns immediately to disable keep-alive.
	//
	// KeepAlive is not used by the generated client.
	KeepAlive func(ctx context.Context, s WithHeadersOKSender) error
	// contains filtered or unexported fields
}

WithHeadersOK is a Server-Sent Events response stream.

func (*WithHeadersOK) All

All iterates over stream events until the stream is closed, reconnecting when needed.

func (*WithHeadersOK) Close

func (s *WithHeadersOK) Close() error

Close closes the current stream and stops further reconnect attempts.

func (*WithHeadersOK) Next

Next returns the next event from the stream, reconnecting when needed.

func (*WithHeadersOK) State

func (s *WithHeadersOK) State() (state sse.State, latestErr error)

State returns the current stream state and the latest terminal or current reconnect error.

type WithHeadersOKClient

type WithHeadersOKClient interface {
	sse.Client[WithHeadersOKEvent]
}

WithHeadersOKClient reads events from the WithHeadersOK SSE stream.

type WithHeadersOKEvent

type WithHeadersOKEvent struct {
	ID    string  `json:"id"`
	Type  string  `json:"event"`
	Data  Message `json:"data"`
	Retry OptInt  `json:"retry"`
}

WithHeadersOKEvent is a parsed Server-Sent Event.

func (*WithHeadersOKEvent) GetData

func (s *WithHeadersOKEvent) GetData() Message

GetData returns the value of Data.

func (*WithHeadersOKEvent) GetID

func (s *WithHeadersOKEvent) GetID() string

GetID returns the value of ID.

func (*WithHeadersOKEvent) GetRetry

func (s *WithHeadersOKEvent) GetRetry() OptInt

GetRetry returns the value of Retry.

func (*WithHeadersOKEvent) GetType

func (s *WithHeadersOKEvent) GetType() string

GetType returns the value of Type.

func (*WithHeadersOKEvent) SetData

func (s *WithHeadersOKEvent) SetData(val Message)

SetData sets the value of Data.

func (*WithHeadersOKEvent) SetID

func (s *WithHeadersOKEvent) SetID(val string)

SetID sets the value of ID.

func (*WithHeadersOKEvent) SetRetry

func (s *WithHeadersOKEvent) SetRetry(val OptInt)

SetRetry sets the value of Retry.

func (*WithHeadersOKEvent) SetType

func (s *WithHeadersOKEvent) SetType(val string)

SetType sets the value of Type.

func (*WithHeadersOKEvent) Validate

func (s *WithHeadersOKEvent) Validate() error

type WithHeadersOKHeaders

type WithHeadersOKHeaders struct {
	XStreamID string
	Response  *WithHeadersOK
}

WithHeadersOKHeaders wraps WithHeadersOK with response headers.

func (*WithHeadersOKHeaders) GetResponse

func (s *WithHeadersOKHeaders) GetResponse() *WithHeadersOK

GetResponse returns the value of Response.

func (*WithHeadersOKHeaders) GetXStreamID

func (s *WithHeadersOKHeaders) GetXStreamID() string

GetXStreamID returns the value of XStreamID.

func (*WithHeadersOKHeaders) SetResponse

func (s *WithHeadersOKHeaders) SetResponse(val *WithHeadersOK)

SetResponse sets the value of Response.

func (*WithHeadersOKHeaders) SetXStreamID

func (s *WithHeadersOKHeaders) SetXStreamID(val string)

SetXStreamID sets the value of XStreamID.

type WithHeadersOKSender

type WithHeadersOKSender interface {
	sse.Sender[WithHeadersOKEvent]
}

WithHeadersOKSender sends events to the WithHeadersOK SSE stream.

Jump to

Keyboard shortcuts

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