goutils

package module
v1.0.26 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: MIT Imports: 5 Imported by: 0

README

goutils

PkgGoDev

Go utils.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NotFoundHandler added in v1.0.20

func NotFoundHandler() http.Handler

func TokenFromHeader added in v1.0.22

func TokenFromHeader(r *http.Request) string

func WriteBadRequest

func WriteBadRequest(w http.ResponseWriter, details interface{})

func WriteCreated

func WriteCreated(w http.ResponseWriter, data, meta interface{})

func WriteInternalError

func WriteInternalError(w http.ResponseWriter, details interface{})

func WriteNoContent

func WriteNoContent(w http.ResponseWriter)

func WriteNotFound

func WriteNotFound(w http.ResponseWriter, details interface{})

func WriteOK

func WriteOK(w http.ResponseWriter, data, meta interface{})

func WriteResponse

func WriteResponse(w http.ResponseWriter, code int, body interface{})

func WriteUnauthorized

func WriteUnauthorized(w http.ResponseWriter, details interface{})

func WriteValidationError added in v1.0.10

func WriteValidationError(w http.ResponseWriter, err error)

Types

type DataResponse

type DataResponse struct {
	Data interface{} `json:"data"`
	Meta interface{} `json:"meta,omitempty"`
}

func NewDataResponse

func NewDataResponse(data, meta interface{}) *DataResponse

type ErrorResponse

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

func NewErrorResponse

func NewErrorResponse(code string, details interface{}) *ErrorResponse

type ErrorResponseError

type ErrorResponseError struct {
	Code    string      `json:"code"`
	Details interface{} `json:"details,omitempty"`
}

type SPAHandler added in v1.0.21

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

func NewSPAHandler added in v1.0.21

func NewSPAHandler(fsys fs.FS, dirPath string, indexPath string, prepareResponse func(http.ResponseWriter, *http.Request, bool)) (*SPAHandler, error)

func (*SPAHandler) ServeHTTP added in v1.0.21

func (h *SPAHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ValidationError

type ValidationError struct {
	ErrorMap map[string]string
}

func NewValidationError

func NewValidationError(errorMap map[string]string) *ValidationError

func (*ValidationError) Error

func (v *ValidationError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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