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 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 ¶
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") ErrImmutableModel = errors.New("serverops: immutable model") ErrImmutablePool = errors.New("serverops: immutable pool") ErrMissingParameter = errors.New("serverops: missing parameter") ErrEmptyRequest = errors.New("serverops: empty request") ErrEmptyRequestBody = errors.New("serverops: empty request body") )
View Source
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
View Source
var ErrFileEmpty = errors.New("serverops: file cannot be empty")
ErrFileEmpty indicates an attempt to upload an empty file.
View Source
var ErrFileSizeLimitExceeded = errors.New("serverops: file size limit exceeded")
ErrFileSizeLimitExceeded indicates the specific file exceeded its allowed size limit.
View Source
var ErrInvalidChain = errors.New("invalid chain definition")
Functions ¶
func EnforceToken ¶ added in v0.0.17
func GetVersion ¶ added in v0.0.25
func GetVersion() string
func HandleAPIError ¶ added in v0.0.4
HandleAPIError processes error responses from the API
func IsAPIError ¶ added in v0.0.4
IsAPIError checks if an error is an APIError
Types ¶
type APIError ¶ added in v0.0.4
type APIError struct {
ErrorProperty string `json:"error"`
}
APIError represents an error response from the API
type AboutServer ¶ added in v0.0.25
type ContextKey ¶ added in v0.0.17
type ContextKey string
const (
ContextTokenKey ContextKey = "token"
)
Click to show internal directories.
Click to hide internal directories.