Documentation
¶
Index ¶
- Variables
- func Decode[T any](r *http.Request) (T, error)
- func Encode[T any](w http.ResponseWriter, _ *http.Request, status int, v T) error
- func EnforceToken(token string, next http.Handler) http.Handler
- func Error(w http.ResponseWriter, r *http.Request, err error, op Operation) error
- func GetPathParam(r *http.Request, name string, description string) string
- func GetQueryParam(r *http.Request, name, defaultValue, description string) string
- func GetVersion() string
- func HandleAPIError(resp *http.Response) error
- func IsAPIError(err error) bool
- func RequestIDMiddleware(next http.Handler) http.Handler
- func TokenMiddleware(next http.Handler) http.Handler
- func TracingMiddleware(next http.Handler) http.Handler
- type APIError
- type AboutServer
- type ContextKey
- type Operation
Constants ¶
This section is empty.
Variables ¶
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") )
var ( ErrInvalidParameterValue = errors.New("serverops: invalid parameter value type") ErrBadPathValue = errors.New("serverops: bad path 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") )
var ( // ErrBadRequest is a generic error for a 400 Bad Request ErrBadRequest = errors.New("serverops: bad request") // ErrUnprocessableEntity is a generic error for a 422 Unprocessable Entity ErrUnprocessableEntity = errors.New("serverops: unprocessable entity") // ErrNotFound is a generic error for a 404 Not Found ErrNotFound = errors.New("serverops: not found") // ErrConflict is a generic error for a 409 Conflict ErrConflict = errors.New("serverops: conflict") // ErrForbidden is a generic error for a 403 Forbidden ErrForbidden = errors.New("serverops: forbidden") // ErrInternalServerError is a generic error for a 500 Internal Server Error ErrInternalServerError = errors.New("serverops: internal server error") // ErrUnsupportedMediaType is a generic error for a 415 Unsupported Media Type ErrUnsupportedMediaType = errors.New("serverops: unsupported media type") ErrUnauthorized = errors.New("serverops: unauthorized") )
The generic error types for common HTTP status codes
var ErrFileEmpty = errors.New("serverops: file cannot be empty")
ErrFileEmpty indicates an attempt to upload an empty file.
var ErrFileSizeLimitExceeded = errors.New("serverops: file size limit exceeded")
ErrFileSizeLimitExceeded indicates the specific file exceeded its allowed size limit.
var ErrInvalidChain = errors.New("invalid chain definition")
Functions ¶
func GetPathParam ¶
GetPathParam retrieves a URL path parameter by name and is used to enforce that all path parameters are documented for the OpenAPI generator. The description argument is not used at runtime but is required for API spec generation.
func GetQueryParam ¶
GetQueryParam retrieves a URL query parameter by name. If the parameter is not present, it returns the provided defaultValue. The description is used for OpenAPI generation.
func GetVersion ¶
func GetVersion() string
func HandleAPIError ¶
HandleAPIError processes error responses from the API
Types ¶
type APIError ¶
type APIError struct {
ErrorProperty string `json:"error"`
}
APIError represents an error response from the API