Documentation
¶
Index ¶
- func WithServerURL(ctx context.Context, u *url.URL) context.Context
- type Alias
- type Client
- type ClientOption
- type ErrorHandler
- type Handler
- type Invoker
- type Labeler
- type Middleware
- type OperationName
- type OptAlias
- func (o *OptAlias) Decode(d *jx.Decoder) error
- func (o OptAlias) Encode(e *jx.Encoder)
- func (o OptAlias) Get() (v Alias, ok bool)
- func (o OptAlias) IsSet() bool
- func (s OptAlias) MarshalJSON() ([]byte, error)
- func (o OptAlias) Or(d Alias) Alias
- func (o *OptAlias) Reset()
- func (o *OptAlias) SetTo(v Alias)
- func (s *OptAlias) UnmarshalJSON(data []byte) error
- type OptDate
- func (o *OptDate) Decode(d *jx.Decoder, format func(*jx.Decoder) (time.Time, error)) error
- func (o OptDate) Encode(e *jx.Encoder, format func(*jx.Encoder, time.Time))
- func (o OptDate) Get() (v time.Time, ok bool)
- func (o OptDate) IsSet() bool
- func (s OptDate) MarshalJSON() ([]byte, error)
- func (o OptDate) Or(d time.Time) time.Time
- func (o *OptDate) Reset()
- func (o *OptDate) SetTo(v time.Time)
- func (s *OptDate) UnmarshalJSON(data []byte) error
- type OptDateTime
- func (o *OptDateTime) Decode(d *jx.Decoder, format func(*jx.Decoder) (time.Time, error)) error
- func (o OptDateTime) Encode(e *jx.Encoder, format func(*jx.Encoder, time.Time))
- func (o OptDateTime) Get() (v time.Time, ok bool)
- func (o OptDateTime) IsSet() bool
- func (s OptDateTime) MarshalJSON() ([]byte, error)
- func (o OptDateTime) Or(d time.Time) time.Time
- func (o *OptDateTime) Reset()
- func (o *OptDateTime) SetTo(v time.Time)
- func (s *OptDateTime) UnmarshalJSON(data []byte) error
- type OptTime
- func (o *OptTime) Decode(d *jx.Decoder, format func(*jx.Decoder) (time.Time, error)) error
- func (o OptTime) Encode(e *jx.Encoder, format func(*jx.Encoder, time.Time))
- func (o OptTime) Get() (v time.Time, ok bool)
- func (o OptTime) IsSet() bool
- func (s OptTime) MarshalJSON() ([]byte, error)
- func (o OptTime) Or(d time.Time) time.Time
- func (o *OptTime) Reset()
- func (o *OptTime) SetTo(v time.Time)
- func (s *OptTime) UnmarshalJSON(data []byte) error
- type Option
- type OptionalOK
- func (s *OptionalOK) Decode(d *jx.Decoder) error
- func (s *OptionalOK) Encode(e *jx.Encoder)
- func (s *OptionalOK) GetAlias() OptAlias
- func (s *OptionalOK) GetDate() OptDate
- func (s *OptionalOK) GetDateTime() OptDateTime
- func (s *OptionalOK) GetTime() OptTime
- func (s *OptionalOK) MarshalJSON() ([]byte, error)
- func (s *OptionalOK) SetAlias(val OptAlias)
- func (s *OptionalOK) SetDate(val OptDate)
- func (s *OptionalOK) SetDateTime(val OptDateTime)
- func (s *OptionalOK) SetTime(val OptTime)
- func (s *OptionalOK) UnmarshalJSON(data []byte) error
- type OptionalParams
- type RequiredOK
- func (s *RequiredOK) Decode(d *jx.Decoder) error
- func (s *RequiredOK) Encode(e *jx.Encoder)
- func (s *RequiredOK) GetAlias() Alias
- func (s *RequiredOK) GetDate() time.Time
- func (s *RequiredOK) GetDateTime() time.Time
- func (s *RequiredOK) GetTime() time.Time
- func (s *RequiredOK) MarshalJSON() ([]byte, error)
- func (s *RequiredOK) SetAlias(val Alias)
- func (s *RequiredOK) SetDate(val time.Time)
- func (s *RequiredOK) SetDateTime(val time.Time)
- func (s *RequiredOK) SetTime(val time.Time)
- func (s *RequiredOK) UnmarshalJSON(data []byte) error
- type RequiredParams
- type Route
- type Server
- type ServerOption
- func WithErrorHandler(h ErrorHandler) ServerOption
- func WithMaxMultipartMemory(max int64) ServerOption
- func WithMethodNotAllowed(methodNotAllowed func(w http.ResponseWriter, r *http.Request, allowed string)) ServerOption
- func WithMiddleware(m ...Middleware) ServerOption
- func WithNotFound(notFound http.HandlerFunc) ServerOption
- func WithPathPrefix(prefix string) ServerOption
- type UnimplementedHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Alias ¶ added in v1.15.0
func (Alias) MarshalJSON ¶ added in v1.15.0
MarshalJSON implements stdjson.Marshaler.
func (*Alias) UnmarshalJSON ¶ added in v1.15.0
UnmarshalJSON implements stdjson.Unmarshaler.
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) Optional ¶ added in v1.15.0
func (c *Client) Optional(ctx context.Context, params OptionalParams) (*OptionalOK, error)
Optional invokes optional operation.
GET /optional
func (*Client) Required ¶
func (c *Client) Required(ctx context.Context, params RequiredParams) (*RequiredOK, error)
Required invokes required operation.
GET /required
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.
type Handler ¶
type Handler interface {
// Optional implements optional operation.
//
// GET /optional
Optional(ctx context.Context, params OptionalParams) (*OptionalOK, error)
// Required implements required operation.
//
// GET /required
Required(ctx context.Context, params RequiredParams) (*RequiredOK, error)
}
Handler handles operations described by OpenAPI v3 specification.
type Invoker ¶
type Invoker interface {
// Optional invokes optional operation.
//
// GET /optional
Optional(ctx context.Context, params OptionalParams) (*OptionalOK, error)
// Required invokes required operation.
//
// GET /required
Required(ctx context.Context, params RequiredParams) (*RequiredOK, 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 ¶
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) AttributeSet ¶
AttributeSet returns the attributes added to the Labeler as an attribute.Set.
type OperationName ¶ added in v1.7.0
type OperationName = string
OperationName is the ogen operation name
const ( OptionalOperation OperationName = "Optional" RequiredOperation OperationName = "Required" )
type OptAlias ¶ added in v1.15.0
OptAlias is optional Alias.
func NewOptAlias ¶ added in v1.15.0
NewOptAlias returns new OptAlias with value set to v.
func (OptAlias) Get ¶ added in v1.15.0
Get returns value and boolean that denotes whether value was set.
func (OptAlias) MarshalJSON ¶ added in v1.15.0
MarshalJSON implements stdjson.Marshaler.
func (*OptAlias) UnmarshalJSON ¶ added in v1.15.0
UnmarshalJSON implements stdjson.Unmarshaler.
type OptDate ¶
OptDate is optional time.Time.
func NewOptDate ¶
NewOptDate returns new OptDate with value set to v.
func (OptDate) MarshalJSON ¶
MarshalJSON implements stdjson.Marshaler.
func (*OptDate) UnmarshalJSON ¶
UnmarshalJSON implements stdjson.Unmarshaler.
type OptDateTime ¶
OptDateTime is optional time.Time.
func NewOptDateTime ¶
func NewOptDateTime(v time.Time) OptDateTime
NewOptDateTime returns new OptDateTime with value set to v.
func (OptDateTime) Get ¶
func (o OptDateTime) Get() (v time.Time, ok bool)
Get returns value and boolean that denotes whether value was set.
func (OptDateTime) IsSet ¶
func (o OptDateTime) IsSet() bool
IsSet returns true if OptDateTime was set.
func (OptDateTime) MarshalJSON ¶
func (s OptDateTime) MarshalJSON() ([]byte, error)
MarshalJSON implements stdjson.Marshaler.
func (OptDateTime) Or ¶
func (o OptDateTime) Or(d time.Time) time.Time
Or returns value if set, or given parameter if does not.
func (*OptDateTime) UnmarshalJSON ¶
func (s *OptDateTime) UnmarshalJSON(data []byte) error
UnmarshalJSON implements stdjson.Unmarshaler.
type OptTime ¶
OptTime is optional time.Time.
func NewOptTime ¶
NewOptTime returns new OptTime with value set to v.
func (OptTime) MarshalJSON ¶
MarshalJSON implements stdjson.Marshaler.
func (*OptTime) UnmarshalJSON ¶
UnmarshalJSON implements stdjson.Unmarshaler.
type Option ¶
type Option interface {
ServerOption
ClientOption
}
Option is config option.
func WithAttributes ¶ added in v1.15.0
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 OptionalOK ¶ added in v1.15.0
type OptionalOK struct {
Date OptDate `json:"date"`
Time OptTime `json:"time"`
DateTime OptDateTime `json:"dateTime"`
Alias OptAlias `json:"alias"`
}
func (*OptionalOK) Decode ¶ added in v1.15.0
func (s *OptionalOK) Decode(d *jx.Decoder) error
Decode decodes OptionalOK from json.
func (*OptionalOK) Encode ¶ added in v1.15.0
func (s *OptionalOK) Encode(e *jx.Encoder)
Encode implements json.Marshaler.
func (*OptionalOK) GetAlias ¶ added in v1.15.0
func (s *OptionalOK) GetAlias() OptAlias
GetAlias returns the value of Alias.
func (*OptionalOK) GetDate ¶ added in v1.15.0
func (s *OptionalOK) GetDate() OptDate
GetDate returns the value of Date.
func (*OptionalOK) GetDateTime ¶ added in v1.15.0
func (s *OptionalOK) GetDateTime() OptDateTime
GetDateTime returns the value of DateTime.
func (*OptionalOK) GetTime ¶ added in v1.15.0
func (s *OptionalOK) GetTime() OptTime
GetTime returns the value of Time.
func (*OptionalOK) MarshalJSON ¶ added in v1.15.0
func (s *OptionalOK) MarshalJSON() ([]byte, error)
MarshalJSON implements stdjson.Marshaler.
func (*OptionalOK) SetAlias ¶ added in v1.15.0
func (s *OptionalOK) SetAlias(val OptAlias)
SetAlias sets the value of Alias.
func (*OptionalOK) SetDate ¶ added in v1.15.0
func (s *OptionalOK) SetDate(val OptDate)
SetDate sets the value of Date.
func (*OptionalOK) SetDateTime ¶ added in v1.15.0
func (s *OptionalOK) SetDateTime(val OptDateTime)
SetDateTime sets the value of DateTime.
func (*OptionalOK) SetTime ¶ added in v1.15.0
func (s *OptionalOK) SetTime(val OptTime)
SetTime sets the value of Time.
func (*OptionalOK) UnmarshalJSON ¶ added in v1.15.0
func (s *OptionalOK) UnmarshalJSON(data []byte) error
UnmarshalJSON implements stdjson.Unmarshaler.
type OptionalParams ¶ added in v1.15.0
type OptionalParams struct {
Date OptDate `json:",omitempty,omitzero"`
Time OptTime `json:",omitempty,omitzero"`
DateTime OptDateTime `json:",omitempty,omitzero"`
Alias OptAlias `json:",omitempty,omitzero"`
}
OptionalParams is parameters of optional operation.
type RequiredOK ¶
type RequiredOK struct {
Date time.Time `json:"date"`
Time time.Time `json:"time"`
DateTime time.Time `json:"dateTime"`
Alias Alias `json:"alias"`
}
func (*RequiredOK) Decode ¶
func (s *RequiredOK) Decode(d *jx.Decoder) error
Decode decodes RequiredOK from json.
func (*RequiredOK) Encode ¶
func (s *RequiredOK) Encode(e *jx.Encoder)
Encode implements json.Marshaler.
func (*RequiredOK) GetAlias ¶ added in v1.15.0
func (s *RequiredOK) GetAlias() Alias
GetAlias returns the value of Alias.
func (*RequiredOK) GetDate ¶
func (s *RequiredOK) GetDate() time.Time
GetDate returns the value of Date.
func (*RequiredOK) GetDateTime ¶
func (s *RequiredOK) GetDateTime() time.Time
GetDateTime returns the value of DateTime.
func (*RequiredOK) GetTime ¶
func (s *RequiredOK) GetTime() time.Time
GetTime returns the value of Time.
func (*RequiredOK) MarshalJSON ¶
func (s *RequiredOK) MarshalJSON() ([]byte, error)
MarshalJSON implements stdjson.Marshaler.
func (*RequiredOK) SetAlias ¶ added in v1.15.0
func (s *RequiredOK) SetAlias(val Alias)
SetAlias sets the value of Alias.
func (*RequiredOK) SetDate ¶
func (s *RequiredOK) SetDate(val time.Time)
SetDate sets the value of Date.
func (*RequiredOK) SetDateTime ¶
func (s *RequiredOK) SetDateTime(val time.Time)
SetDateTime sets the value of DateTime.
func (*RequiredOK) SetTime ¶
func (s *RequiredOK) SetTime(val time.Time)
SetTime sets the value of Time.
func (*RequiredOK) UnmarshalJSON ¶
func (s *RequiredOK) UnmarshalJSON(data []byte) error
UnmarshalJSON implements stdjson.Unmarshaler.
type RequiredParams ¶
RequiredParams is parameters of required operation.
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route is route object.
func (Route) OperationGroup ¶ added in v1.17.0
OperationGroup returns the x-ogen-operation-group value.
func (Route) OperationID ¶
OperationID returns OpenAPI operationId.
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.
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) Optional ¶ added in v1.15.0
func (UnimplementedHandler) Optional(ctx context.Context, params OptionalParams) (r *OptionalOK, _ error)
Optional implements optional operation.
GET /optional
func (UnimplementedHandler) Required ¶
func (UnimplementedHandler) Required(ctx context.Context, params RequiredParams) (r *RequiredOK, _ error)
Required implements required operation.
GET /required
Source Files
¶
- oas_cfg_gen.go
- oas_client_gen.go
- oas_defaults_gen.go
- oas_handlers_gen.go
- oas_json_gen.go
- oas_labeler_gen.go
- oas_middleware_gen.go
- oas_operations_gen.go
- oas_parameters_gen.go
- oas_request_decoders_gen.go
- oas_request_encoders_gen.go
- oas_response_decoders_gen.go
- oas_response_encoders_gen.go
- oas_router_gen.go
- oas_schemas_gen.go
- oas_server_gen.go
- oas_unimplemented_gen.go