Documentation ¶
Index ¶
- func WithServerURL(ctx context.Context, u *url.URL) context.Context
- type Client
- type ClientOption
- type Data
- type Error
- func (s *Error) Decode(d *jx.Decoder) error
- func (s *Error) Encode(e *jx.Encoder)
- func (s *Error) GetCode() int64
- func (s *Error) GetMessage() string
- func (s *Error) MarshalJSON() ([]byte, error)
- func (s *Error) SetCode(val int64)
- func (s *Error) SetMessage(val string)
- func (s *Error) UnmarshalJSON(data []byte) error
- type ErrorHandler
- type ErrorStatusCode
- type Handler
- type Invoker
- type Middleware
- type OptData
- func (o *OptData) Decode(d *jx.Decoder) error
- func (o OptData) Encode(e *jx.Encoder)
- func (o OptData) Get() (v Data, ok bool)
- func (o OptData) IsSet() bool
- func (s OptData) MarshalJSON() ([]byte, error)
- func (o OptData) Or(d Data) Data
- func (o *OptData) Reset()
- func (o *OptData) SetTo(v Data)
- func (s *OptData) UnmarshalJSON(data []byte) error
- type Option
- 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 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.
type ClientOption ¶ added in v0.55.0
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 Data ¶
type Data struct {
Name string `json:"name"`
}
Some data. Ref: #/components/schemas/Data
func (*Data) MarshalJSON ¶
MarshalJSON implements stdjson.Marshaler.
func (*Data) UnmarshalJSON ¶
UnmarshalJSON implements stdjson.Unmarshaler.
type Error ¶
Represents error object. Ref: #/components/schemas/Error
func (*Error) GetMessage ¶
GetMessage returns the value of Message.
func (*Error) MarshalJSON ¶
MarshalJSON implements stdjson.Marshaler.
func (*Error) SetMessage ¶
SetMessage sets the value of Message.
func (*Error) UnmarshalJSON ¶
UnmarshalJSON implements stdjson.Unmarshaler.
type ErrorStatusCode ¶
ErrorStatusCode wraps Error with StatusCode.
func (*ErrorStatusCode) Error ¶
func (s *ErrorStatusCode) Error() string
func (*ErrorStatusCode) GetResponse ¶
func (s *ErrorStatusCode) GetResponse() Error
GetResponse returns the value of Response.
func (*ErrorStatusCode) GetStatusCode ¶
func (s *ErrorStatusCode) GetStatusCode() int
GetStatusCode returns the value of StatusCode.
func (*ErrorStatusCode) SetResponse ¶
func (s *ErrorStatusCode) SetResponse(val Error)
SetResponse sets the value of Response.
func (*ErrorStatusCode) SetStatusCode ¶
func (s *ErrorStatusCode) SetStatusCode(val int)
SetStatusCode sets the value of StatusCode.
type Handler ¶
type Handler interface { // DataCreate implements dataCreate operation. // // Creates data. // // POST /data DataCreate(ctx context.Context, req OptData) (*Data, error) // DataGet implements dataGet operation. // // Retrieve data. // // GET /data DataGet(ctx context.Context) (*Data, error) // NewError creates *ErrorStatusCode from error returned by handler. // // Used for common default response. NewError(ctx context.Context, err error) *ErrorStatusCode }
Handler handles operations described by OpenAPI v3 specification.
type Invoker ¶ added in v0.75.0
type Invoker interface { // DataCreate invokes dataCreate operation. // // Creates data. // // POST /data DataCreate(ctx context.Context, request OptData) (*Data, error) // DataGet invokes dataGet operation. // // Retrieve data. // // GET /data DataGet(ctx context.Context) (*Data, error) }
Invoker invokes operations described by OpenAPI v3 specification.
type OptData ¶
OptData is optional Data.
func NewOptData ¶
NewOptData returns new OptData with value set to v.
func (OptData) MarshalJSON ¶
MarshalJSON implements stdjson.Marshaler.
func (*OptData) UnmarshalJSON ¶
UnmarshalJSON implements stdjson.Unmarshaler.
type Option ¶
type Option interface { ServerOption ClientOption }
Option is config option.
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 Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route is route object.
func (Route) OperationID ¶
OperationID returns OpenAPI operationId.
func (Route) PathPattern ¶ added in v0.58.0
PathPattern returns OpenAPI path.
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 ¶ added in v0.55.0
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) DataCreate ¶
DataCreate implements dataCreate operation.
Creates data.
POST /data
func (UnimplementedHandler) DataGet ¶
func (UnimplementedHandler) DataGet(ctx context.Context) (r *Data, _ error)
DataGet implements dataGet operation.
Retrieve data.
GET /data
func (UnimplementedHandler) NewError ¶
func (UnimplementedHandler) NewError(ctx context.Context, err error) (r *ErrorStatusCode)
NewError creates *ErrorStatusCode from error returned by handler.
Used for common default response.