service

package
v0.0.0-...-bf09d72 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Int32PointerFromQueryParam

func Int32PointerFromQueryParam(r *http.Request, paramName string) (*int32, error)

Int32PointerFromQueryParam returns a nullable int32 from a query param key

func Int64ArrayFromQueryParam

func Int64ArrayFromQueryParam(r *http.Request, paramName string) ([]int64, error)

func ReturnProblem

func ReturnProblem(w http.ResponseWriter, detail, code string, status int, innerErr error) (int, []byte)

ReturnProblem will return a json http problem response

func TimestampFromQueryParam

func TimestampFromQueryParam(r *http.Request, paramName string) (*time.Time, error)

func WriteJSONResponse

func WriteJSONResponse(w http.ResponseWriter, status int, data interface{}) error

WriteJSONResponse will write a json response to the htt.ResponseWriter

func WriteProblem

func WriteProblem(w http.ResponseWriter, detail, code string, status int, innerErr error) error

WriteProblem will write a json http problem response

Types

type PagingParams

type PagingParams struct {
	PageSize   *int32 `json:"page_size"`
	Offset     *int32 `json:"offset"`
	SortFields []Sort `json:"sort_fields"`
}

PagingParams represents paging and sorting parameter values

func ParsePagingParams

func ParsePagingParams(r *http.Request, defaults PagingParams, sortFieldsWhitelist []string) (PagingParams, error)

ParsePagingParams retrieves paging params from the request, allows for whitelisting sort field values

type Server

type Server interface {
	GetRouter() *vestigo.Router
	GetEnvironment() string
	GetServiceName() string
}

Server can GetRouter

type Sort

type Sort struct {
	Field     string `json:"field"`
	Direction string `json:"direction"`
}

func (Sort) Valid

func (s Sort) Valid(fieldWhiteList []string) bool

Jump to

Keyboard shortcuts

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