response

package
v1.0.1-0...-d3c69d1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(w http.ResponseWriter, r *http.Request, status int, data interface{})

Encode data to HTTP response

func Failure

func Failure(w http.ResponseWriter, status int, err ErrorMessage)

Failure response

func FailureFromError

func FailureFromError(w http.ResponseWriter, status int, err error)

FailureFromError write ErrorMessage from error

func FailureFromValidator

func FailureFromValidator(w http.ResponseWriter, result *validate.Result)

FailureFromValidator response

func InternalServerFailure

func InternalServerFailure(w http.ResponseWriter)

InternalServerFailure response

func MethodNotAllowedFailure

func MethodNotAllowedFailure(w http.ResponseWriter, r *http.Request)

MethodNotAllowedFailure response

func NotFoundFailure

func NotFoundFailure(w http.ResponseWriter, r *http.Request)

NotFoundFailure response

func Register

func Register(encoder encoder.Encoder)

Register encoder provider

func ServiceUnavailableFailure

func ServiceUnavailableFailure(w http.ResponseWriter, retry time.Duration)

ServiceUnavailableFailure response

func StatusCode

func StatusCode(w http.ResponseWriter) int

StatusCode returns the HTTP response status. Remember that the status is only set by the server after WriteHeader has been called.

Types

type ErrorMessage

type ErrorMessage struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ErrorMessage struct

func (ErrorMessage) Error

func (e ErrorMessage) Error() string

Error implements ErrorMessageInterface

func (ErrorMessage) GetCode

func (e ErrorMessage) GetCode() int

GetCode implements ErrorMessageInterface

func (ErrorMessage) GetMessage

func (e ErrorMessage) GetMessage() string

GetMessage implements ErrorMessageInterface

type ErrorMessageInterface

type ErrorMessageInterface interface {
	GetCode() int
	GetMessage() string
	Error() string
}

ErrorMessageInterface interface

type ErrorResponse

type ErrorResponse struct {
	Error ErrorMessage `json:"error"`
}

ErrorResponse struct

type ErrorsResponse

type ErrorsResponse struct {
	Errors []error `json:"errors"`
}

ErrorsResponse struct

type ValidatorError

type ValidatorError struct {
	Code    int32         `json:"code,omitempty"`
	Name    string        `json:"name,omitempty"`
	In      string        `json:"in,omitempty"`
	Value   interface{}   `json:"value,omitempty"`
	Message string        `json:"message"`
	Values  []interface{} `json:"values,omitempty"`
}

ValidatorError struct

func (ValidatorError) Error

func (e ValidatorError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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