apiframework

package
v1.0.0-rc.12 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 19 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

Index

Constants

View Source
const (
	CursorParamDescription = "An optional RFC3339Nano timestamp to fetch the next page of results."
	LimitParamDescription  = "The maximum number of items to return per page."
)
View Source
const MaxRequestIDLength = 128

Variables

View Source
var (
	ErrEncodeInvalidJSON      = errors.New("serverops: encoding failing, invalid json")
	ErrDecodeInvalidJSON      = errors.New("serverops: decoding failing, invalid json")
	ErrDecodeInvalidYAML      = errors.New("serverops: decoding failing, invalid yaml")
	ErrDecodeBase64           = errors.New("serverops: decoding failing, invalid base64 data")
	ErrUnsupportedContentType = errors.New("serverops: unsupported content type for decoding")
	ErrReadingRequestBody     = errors.New("serverops: failed to read request body")
	ErrMalformedContentType   = errors.New("serverops: malformed Content-Type header")
)
View Source
var (
	ErrInvalidParameterValue = errors.New("serverops: invalid parameter value type")
	ErrBadPathValue          = errors.New("serverops: bad path value")
	ErrBadQueryValue         = errors.New("serverops: bad query value")
	ErrImmutableModel        = errors.New("serverops: immutable model")
	ErrImmutableGroup        = errors.New("serverops: immutable group")
	ErrMissingParameter      = errors.New("serverops: missing parameter")
	ErrEmptyRequest          = errors.New("serverops: empty request")
	ErrEmptyRequestBody      = errors.New("serverops: empty request body")
	ErrInvalidChain          = errors.New("serverops: invalid chain definition")

	ErrBadRequest            = errors.New("serverops: bad request")
	ErrUnprocessableEntity   = errors.New("serverops: unprocessable entity")
	ErrNotFound              = errors.New("serverops: not found")
	ErrConflict              = errors.New("serverops: conflict")
	ErrForbidden             = errors.New("serverops: forbidden")
	ErrInternalServerError   = errors.New("serverops: internal server error")
	ErrUnsupportedMediaType  = errors.New("serverops: unsupported media type")
	ErrUnauthorized          = errors.New("serverops: unauthorized")
	ErrFileSizeLimitExceeded = errors.New("serverops: file size limit exceeded")
	ErrFileEmpty             = errors.New("serverops: file cannot be empty")
)

Functions

func CursorParam

func CursorParam(r *http.Request) (*time.Time, error)

func Decode

func Decode[T any](r *http.Request) (T, error)

func Encode

func Encode[T any](w http.ResponseWriter, _ *http.Request, status int, v T) error

func EnforceToken added in v0.0.17

func EnforceToken(expectedToken string, next http.Handler) http.Handler

func Error

func Error(w http.ResponseWriter, r *http.Request, err error, op Operation) error

func GetErrorParam added in v0.28.2

func GetErrorParam(err error) string

func GetPathParam added in v0.28.2

func GetPathParam(r *http.Request, name string, description string) string

func GetQueryParam added in v0.28.2

func GetQueryParam(r *http.Request, name, defaultValue, description string) string

func HandleAPIError added in v0.0.4

func HandleAPIError(resp *http.Response) error

func IsAPIError added in v0.0.4

func IsAPIError(err error) (message, errorCode, errorType, param string, ok bool)

func LimitParam

func LimitParam(r *http.Request, defaultLimit int) (int, error)

func ListParams

func ListParams(r *http.Request, defaultLimit int) (*time.Time, int, error)

func RequestIDMiddleware

func RequestIDMiddleware(next http.Handler) http.Handler

func TokenMiddleware added in v0.0.17

func TokenMiddleware(next http.Handler) http.Handler

func TracingMiddleware added in v0.0.17

func TracingMiddleware(next http.Handler) http.Handler

Types

type APIError added in v0.0.4

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

func BadPathValue added in v0.28.2

func BadPathValue(param string, message ...string) *APIError

func BadRequest added in v0.28.2

func BadRequest(message ...string) *APIError

func Conflict added in v0.28.2

func Conflict(message ...string) *APIError

func FileEmpty added in v0.28.2

func FileEmpty(message ...string) *APIError

func FileSizeLimitExceeded added in v0.28.2

func FileSizeLimitExceeded(message ...string) *APIError

func Forbidden added in v0.28.2

func Forbidden(message ...string) *APIError

func ImmutableGroup added in v0.28.2

func ImmutableGroup(message ...string) *APIError

func ImmutableModel added in v0.28.2

func ImmutableModel(message ...string) *APIError

func InternalServerError added in v0.28.2

func InternalServerError(message ...string) *APIError

func InvalidChain added in v0.28.2

func InvalidChain(message ...string) *APIError

func InvalidParameterValue added in v0.28.2

func InvalidParameterValue(param string, message ...string) *APIError

func MissingParameter added in v0.28.2

func MissingParameter(param string, message ...string) *APIError

func NewAPIError added in v0.28.2

func NewAPIError(err error, message, param string) *APIError

func NotFound added in v0.28.2

func NotFound(message ...string) *APIError

func Unauthorized added in v0.28.2

func Unauthorized(message ...string) *APIError

func UnprocessableEntity added in v0.28.2

func UnprocessableEntity(message ...string) *APIError

func UnsupportedMediaType added in v0.28.2

func UnsupportedMediaType(message ...string) *APIError

func (*APIError) Code added in v0.28.2

func (e *APIError) Code() string

func (*APIError) Error added in v0.0.4

func (e *APIError) Error() string

func (*APIError) Param added in v0.28.2

func (e *APIError) Param() string

func (*APIError) Unwrap added in v0.28.2

func (e *APIError) Unwrap() error

type AboutServer added in v0.0.25

type AboutServer struct {
	Version        string `json:"version"`
	NodeInstanceID string `json:"nodeInstanceID"`
	Tenancy        string `json:"tenancy"`
}

type ContextKey added in v0.0.17

type ContextKey string
const (
	ContextTokenKey ContextKey = "token"
)

type MessageResponse added in v0.28.2

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

type Operation

type Operation uint16
const (
	CreateOperation Operation = iota
	GetOperation
	UpdateOperation
	DeleteOperation
	ListOperation
	AuthorizeOperation
	ServerOperation
	ExecuteOperation
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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