rest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 17 Imported by: ? 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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Envelope

type Envelope struct {
	// Base64 (standard, padded) of the payload JSON bytes.
	Payload string `json:"payload"`
	// The armored OpenSSH signature (`-----BEGIN SSH SIGNATURE-----`) over the decoded payload bytes, in
	// the configured namespace.
	Signature string `json:"signature"`
}

Ref: #/components/schemas/Envelope

func (*Envelope) Decode

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

Decode decodes Envelope from json.

func (*Envelope) Encode

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

Encode implements json.Marshaler.

func (*Envelope) GetPayload

func (s *Envelope) GetPayload() string

GetPayload returns the value of Payload.

func (*Envelope) GetSignature

func (s *Envelope) GetSignature() string

GetSignature returns the value of Signature.

func (*Envelope) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*Envelope) SetPayload

func (s *Envelope) SetPayload(val string)

SetPayload sets the value of Payload.

func (*Envelope) SetSignature

func (s *Envelope) SetSignature(val string)

SetSignature sets the value of Signature.

func (*Envelope) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type EnvelopeHeaders

type EnvelopeHeaders struct {
	CacheControl string
	ETag         string
	Response     Envelope
}

EnvelopeHeaders wraps Envelope with response headers.

func (*EnvelopeHeaders) GetCacheControl

func (s *EnvelopeHeaders) GetCacheControl() string

GetCacheControl returns the value of CacheControl.

func (*EnvelopeHeaders) GetETag

func (s *EnvelopeHeaders) GetETag() string

GetETag returns the value of ETag.

func (*EnvelopeHeaders) GetResponse

func (s *EnvelopeHeaders) GetResponse() Envelope

GetResponse returns the value of Response.

func (*EnvelopeHeaders) SetCacheControl

func (s *EnvelopeHeaders) SetCacheControl(val string)

SetCacheControl sets the value of CacheControl.

func (*EnvelopeHeaders) SetETag

func (s *EnvelopeHeaders) SetETag(val string)

SetETag sets the value of ETag.

func (*EnvelopeHeaders) SetResponse

func (s *EnvelopeHeaders) SetResponse(val Envelope)

SetResponse sets the value of Response.

type ErrorHandler

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type GetListNotModified

type GetListNotModified struct {
	CacheControl string
	ETag         string
}

GetListNotModified is response for GetList operation.

func (*GetListNotModified) GetCacheControl

func (s *GetListNotModified) GetCacheControl() string

GetCacheControl returns the value of CacheControl.

func (*GetListNotModified) GetETag

func (s *GetListNotModified) GetETag() string

GetETag returns the value of ETag.

func (*GetListNotModified) SetCacheControl

func (s *GetListNotModified) SetCacheControl(val string)

SetCacheControl sets the value of CacheControl.

func (*GetListNotModified) SetETag

func (s *GetListNotModified) SetETag(val string)

SetETag sets the value of ETag.

type GetListParams

type GetListParams struct {
	// The ETag of a list the client holds; a match answers 304.
	IfNoneMatch OptString `json:",omitempty,omitzero"`
}

GetListParams is parameters of getList operation.

type GetListRes

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

type Handler

type Handler interface {
	// GetHealth implements getHealth operation.
	//
	// Answers while the daemon serves, whether or not its last run succeeded: a failing source must not
	// restart it.
	//
	// GET /api/v1/health
	GetHealth(ctx context.Context) (*Health, error)
	// GetList implements getList operation.
	//
	// The current list as an envelope of the exact payload bytes and their OpenSSH signature. The
	// payload's format is `Payload`. An unchanged list keeps its generation and is signed again every
	// refresh interval with a new `generated_at`, so its ETag changes then too.
	//
	// GET /api/v1/list
	GetList(ctx context.Context, params GetListParams) (GetListRes, error)
	// NewError creates *ProblemStatusCode from error returned by handler.
	//
	// Used for common default response.
	NewError(ctx context.Context, err error) *ProblemStatusCode
}

Handler handles operations described by OpenAPI v3 specification.

type Health

type Health struct {
	Status HealthStatus `json:"status"`
	// The build's version.
	Version string `json:"version"`
	// The served list's generation; 0 before the first.
	Generation int64 `json:"generation"`
	// When a run last succeeded, in UTC.
	LastSuccess OptDateTime `json:"lastSuccess"`
}

Ref: #/components/schemas/Health

func (*Health) Decode

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

Decode decodes Health from json.

func (*Health) Encode

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

Encode implements json.Marshaler.

func (*Health) GetGeneration

func (s *Health) GetGeneration() int64

GetGeneration returns the value of Generation.

func (*Health) GetLastSuccess

func (s *Health) GetLastSuccess() OptDateTime

GetLastSuccess returns the value of LastSuccess.

func (*Health) GetStatus

func (s *Health) GetStatus() HealthStatus

GetStatus returns the value of Status.

func (*Health) GetVersion

func (s *Health) GetVersion() string

GetVersion returns the value of Version.

func (*Health) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*Health) SetGeneration

func (s *Health) SetGeneration(val int64)

SetGeneration sets the value of Generation.

func (*Health) SetLastSuccess

func (s *Health) SetLastSuccess(val OptDateTime)

SetLastSuccess sets the value of LastSuccess.

func (*Health) SetStatus

func (s *Health) SetStatus(val HealthStatus)

SetStatus sets the value of Status.

func (*Health) SetVersion

func (s *Health) SetVersion(val string)

SetVersion sets the value of Version.

func (*Health) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*Health) Validate

func (s *Health) Validate() error

type HealthStatus

type HealthStatus string
const (
	HealthStatusOk HealthStatus = "ok"
)

func (HealthStatus) AllValues

func (HealthStatus) AllValues() []HealthStatus

AllValues returns all HealthStatus values.

func (*HealthStatus) Decode

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

Decode decodes HealthStatus from json.

func (HealthStatus) Encode

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

Encode encodes HealthStatus as json.

func (HealthStatus) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (HealthStatus) MarshalText

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

MarshalText implements encoding.TextMarshaler.

func (*HealthStatus) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*HealthStatus) UnmarshalText

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

UnmarshalText implements encoding.TextUnmarshaler.

func (HealthStatus) Validate

func (s HealthStatus) Validate() error

type Middleware

type Middleware = middleware.Middleware

Middleware is middleware type.

type OperationName

type OperationName = string

OperationName is the ogen operation name

const (
	GetHealthOperation OperationName = "GetHealth"
	GetListOperation   OperationName = "GetList"
)

type OptDateTime

type OptDateTime struct {
	Value time.Time
	Set   bool
}

OptDateTime is optional time.Time.

func NewOptDateTime

func NewOptDateTime(v time.Time) OptDateTime

NewOptDateTime returns new OptDateTime with value set to v.

func (*OptDateTime) Decode

func (o *OptDateTime) Decode(d *jx.Decoder, format func(*jx.Decoder) (time.Time, error)) error

Decode decodes time.Time from json.

func (OptDateTime) Encode

func (o OptDateTime) Encode(e *jx.Encoder, format func(*jx.Encoder, time.Time))

Encode encodes time.Time as json.

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

func (o *OptDateTime) Reset()

Reset unsets value.

func (*OptDateTime) SetTo

func (o *OptDateTime) SetTo(v time.Time)

SetTo sets value to v.

func (*OptDateTime) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type OptString

type OptString struct {
	Value string
	Set   bool
}

OptString is optional string.

func NewOptString

func NewOptString(v string) OptString

NewOptString returns new OptString with value set to v.

func (*OptString) Decode

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

Decode decodes string from json.

func (OptString) Encode

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

Encode encodes string as json.

func (OptString) Get

func (o OptString) Get() (v string, ok bool)

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

func (OptString) IsSet

func (o OptString) IsSet() bool

IsSet returns true if OptString was set.

func (OptString) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptString) Or

func (o OptString) Or(d string) string

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

func (*OptString) Reset

func (o *OptString) Reset()

Reset unsets value.

func (*OptString) SetTo

func (o *OptString) SetTo(v string)

SetTo sets value to v.

func (*OptString) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type OptURI

type OptURI struct {
	Value url.URL
	Set   bool
}

OptURI is optional url.URL.

func NewOptURI

func NewOptURI(v url.URL) OptURI

NewOptURI returns new OptURI with value set to v.

func (*OptURI) Decode

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

Decode decodes url.URL from json.

func (OptURI) Encode

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

Encode encodes url.URL as json.

func (OptURI) Get

func (o OptURI) Get() (v url.URL, ok bool)

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

func (OptURI) IsSet

func (o OptURI) IsSet() bool

IsSet returns true if OptURI was set.

func (OptURI) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptURI) Or

func (o OptURI) Or(d url.URL) url.URL

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

func (*OptURI) Reset

func (o *OptURI) Reset()

Reset unsets value.

func (*OptURI) SetTo

func (o *OptURI) SetTo(v url.URL)

SetTo sets value to v.

func (*OptURI) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type Option

type Option interface {
	ServerOption
}

Option is config option.

type Problem

type Problem struct {
	Type     OptURI    `json:"type"`
	Title    string    `json:"title"`
	Status   int       `json:"status"`
	Detail   OptString `json:"detail"`
	Instance OptURI    `json:"instance"`
}

RFC 9457 problem details. Ref: #/components/schemas/Problem

func (*Problem) Decode

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

Decode decodes Problem from json.

func (*Problem) Encode

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

Encode implements json.Marshaler.

func (*Problem) GetDetail

func (s *Problem) GetDetail() OptString

GetDetail returns the value of Detail.

func (*Problem) GetInstance

func (s *Problem) GetInstance() OptURI

GetInstance returns the value of Instance.

func (*Problem) GetStatus

func (s *Problem) GetStatus() int

GetStatus returns the value of Status.

func (*Problem) GetTitle

func (s *Problem) GetTitle() string

GetTitle returns the value of Title.

func (*Problem) GetType

func (s *Problem) GetType() OptURI

GetType returns the value of Type.

func (*Problem) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*Problem) SetDetail

func (s *Problem) SetDetail(val OptString)

SetDetail sets the value of Detail.

func (*Problem) SetInstance

func (s *Problem) SetInstance(val OptURI)

SetInstance sets the value of Instance.

func (*Problem) SetStatus

func (s *Problem) SetStatus(val int)

SetStatus sets the value of Status.

func (*Problem) SetTitle

func (s *Problem) SetTitle(val string)

SetTitle sets the value of Title.

func (*Problem) SetType

func (s *Problem) SetType(val OptURI)

SetType sets the value of Type.

func (*Problem) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*Problem) Validate

func (s *Problem) Validate() error

type ProblemStatusCode

type ProblemStatusCode struct {
	StatusCode int
	Response   Problem
}

ProblemStatusCode wraps Problem with StatusCode.

func (*ProblemStatusCode) Error

func (s *ProblemStatusCode) Error() string

func (*ProblemStatusCode) GetResponse

func (s *ProblemStatusCode) GetResponse() Problem

GetResponse returns the value of Response.

func (*ProblemStatusCode) GetStatusCode

func (s *ProblemStatusCode) GetStatusCode() int

GetStatusCode returns the value of StatusCode.

func (*ProblemStatusCode) SetResponse

func (s *ProblemStatusCode) SetResponse(val Problem)

SetResponse sets the value of Response.

func (*ProblemStatusCode) SetStatusCode

func (s *ProblemStatusCode) SetStatusCode(val int)

SetStatusCode sets the value of StatusCode.

func (*ProblemStatusCode) Validate

func (s *ProblemStatusCode) Validate() error

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 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.

Jump to

Keyboard shortcuts

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