stdresp

package
v0.17.5 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(c http.Context, opts ...StdOpt) http.Response

Error construct standard response with default error response code and description after applying any given options.

func Resp

func Resp(c http.Context, code, desc string, opts ...StdOpt) http.Response

Resp construct standard response after applying the response code and description along with any given options.

func Success

func Success(c http.Context, opts ...StdOpt) http.Response

Success construct standard response with default success response code and description after applying any given options.

Types

type Std

type Std struct {
	ResponseCode       string   `json:"responseCode"`
	ResponseDesc       string   `json:"responseDesc"`
	ResponseData       any      `json:"responseData,omitempty"`
	ResponseValidation []string `json:"responseValidation,omitempty"`
	// contains filtered or unexported fields
}

Std holds standard response structure for brispot microservice.

type StdOpt

type StdOpt func(std *Std)

StdOpt option signature that accept and modify Std response object.

func WithData

func WithData(data any) StdOpt

WithData embed given data object to the standard response as field `responseData`.

func WithDesc

func WithDesc(desc string) StdOpt

WithDesc embed given string data to the standard response as field `responseDesc`.

func WithErr

func WithErr(e error) StdOpt

WithErr embed given error to the standard response.

func WithErrAccess added in v0.17.5

func WithErrAccess(e error) StdOpt

func WithErrHeader added in v0.17.5

func WithErrHeader(e error) StdOpt

func WithErrInvalidRule added in v0.17.5

func WithErrInvalidRule(e error) StdOpt

func WithErrNotFound added in v0.17.5

func WithErrNotFound(e error) StdOpt

func WithErrParameter added in v0.17.5

func WithErrParameter(e error) StdOpt

func WithErrRuntime added in v0.17.5

func WithErrRuntime(e error) StdOpt

func WithErrThirdParty added in v0.16.6

func WithErrThirdParty(e error) StdOpt

func WithErrUnsupport added in v0.17.5

func WithErrUnsupport(e error) StdOpt

func WithErrWaiting added in v0.17.5

func WithErrWaiting(e error) StdOpt

func WithMaskedData added in v0.17.1

func WithMaskedData(keysToMask []string, data any) StdOpt

WithMaskedData masks specified keys in the response data

Jump to

Keyboard shortcuts

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