svc

package
v0.6.9 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(msg string) midl.Response

BadRequest constructs a simple 400 response body.

func InvalidRequest

func InvalidRequest(msg string) midl.Response

InvalidRequest constructs a simple 422 response body.

func NotFound

func NotFound(msg string) midl.Response

NotFound constructs a simple 404 response body.

func ServerError

func ServerError(msg string) midl.Response

ServerError constructs a simple 500 response body.

Types

type ResponseStatus

type ResponseStatus string

ResponseStatus defines a service response status type.

const (
	StatusNotFound   ResponseStatus = "not-found"
	StatusBadRequest ResponseStatus = "bad-request"
	StatusBadInput   ResponseStatus = "invalid-input"
	StatusServerErr  ResponseStatus = "server-error"
	StatusBadMethod  ResponseStatus = "bad-http-method"
)

All possible response status types.

type SadResponse

type SadResponse struct {
	Status  ResponseStatus `json:"status"`
	Message string         `json:"message"`
}

SadResponse defines a generic error response body.

type ValidationBundle

type ValidationBundle struct {
	General []string            `json:"general"`
	ByKey   map[string][]string `json:"byKey"`
}

type ValidationResponse

type ValidationResponse struct {
	Status ResponseStatus   `json:"status"`
	Errors ValidationBundle `json:"reasons"`
}

ValidationResponse defines a 422 error response body.

type ValidationResult

type ValidationResult struct {
	Failed bool
	Result ValidationSet
}

func (*ValidationResult) AddError

func (r *ValidationResult) AddError(key, val string)

type ValidationSet

type ValidationSet map[string][]string

func (ValidationSet) Append

func (s ValidationSet) Append(other ValidationSet)

Jump to

Keyboard shortcuts

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