http

package
v1.127.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Server The operation looked fine on paper, but something went wrong
	Server Type = "server"
	// Missing The thing you mentioned, whatever it is, just doesn't exist
	Missing = "missing"
	// User The operation was well-formed, but you asked for something that
	// can't happen at present (e.g., because you've not supplied some
	// config yet)
	User = "user"
	// Forbidden The operation is not allowed for the current authenticated user
	Forbidden = "forbidden"
)

Variables

This section is empty.

Functions

func ApplicationNotFoundError

func ApplicationNotFoundError(message string, underlyingError error) error

ApplicationNotFoundError indication that application was not found. Can also mean a user does not have access to the application.

func ByteArrayResponse

func ByteArrayResponse(w http.ResponseWriter, r *http.Request, contentType string, result []byte) error

ByteArrayResponse Used for response data. I.e. image

func ErrorResponse

func ErrorResponse(w http.ResponseWriter, r *http.Request, apiError error) error

ErrorResponse Marshals error for user requester

func ErrorResponseForServer

func ErrorResponseForServer(w http.ResponseWriter, r *http.Request, apiError error) error

ErrorResponseForServer Marshals error for server requester

func ForbiddenError

func ForbiddenError(message string) error

ForbiddenError forbidden error

func JSONResponse

func JSONResponse(w http.ResponseWriter, r *http.Request, result any) error

JSONResponse Marshals response with header

func NotFoundError

func NotFoundError(message string) error

NotFoundError No found error

func ReaderFileResponse

func ReaderFileResponse(w http.ResponseWriter, reader io.Reader, fileName, contentType string) error

ReaderFileResponse writes the content from the reader to the response, and sets Content-Disposition=attachment; filename=<filename arg>

func ReaderResponse

func ReaderResponse(w http.ResponseWriter, reader io.Reader, contentType string) error

ReaderResponse writes the content from the reader to the response,

func StringResponse

func StringResponse(w http.ResponseWriter, r *http.Request, result string) error

StringResponse Used for textual response data. I.e. log data

func TypeMissingError

func TypeMissingError(message string, underlyingError error) error

TypeMissingError indication of underlying type missing

func UnexpectedError

func UnexpectedError(message string, underlyingError error) error

UnexpectedError any unexpected error

func ValidationError

func ValidationError(kind, message string) error

ValidationError Used for indication of validation errors

Types

type Error

type Error struct {
	Type Type
	// a message that can be printed out for the user
	Message string `json:"message"`
	// the underlying error that can be e.g., logged for developers to look at
	Err error
}

Error Representation of errors in the API. These are divided into a small number of categories, essentially distinguished by whose fault the error is; i.e., is this error:

  • a transient problem with the service, so worth trying again?
  • not going to work until the user takes some other action, e.g., updating config?

func CoverAllError

func CoverAllError(err error, requesterType Type) *Error

CoverAllError Cover all other errors for requester type Type

func (*Error) Error

func (e *Error) Error() string

func (*Error) MarshalJSON

func (e *Error) MarshalJSON() ([]byte, error)

MarshalJSON Writes error as json

func (*Error) UnmarshalJSON

func (e *Error) UnmarshalJSON(data []byte) error

UnmarshalJSON Parses json

type Type

type Type string

Type Type of error

Jump to

Keyboard shortcuts

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