web

package
v1.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLimitAndOffset

func GetLimitAndOffset(r *http.Request) (limit int, offset int)

GetLimitAndOffset gets and returns the limit and offset from the given request.

func RespondError

func RespondError(w http.ResponseWriter, err error)

RespondError check error type and Write to ResponseWriter.

func RespondErrorMessage

func RespondErrorMessage(w http.ResponseWriter, code int, msg string)

RespondErrorMessage make error response with payload.

func RespondJSON

func RespondJSON(w http.ResponseWriter, code int, payload interface{})

RespondJSON Make response with json formate.

func RespondJSONWithXTotalCount

func RespondJSONWithXTotalCount(w http.ResponseWriter, code int, count int, payload interface{})

RespondJSONWithXTotalCount Make response with json format and add X-Total-Count header.

func SetNewHeader

func SetNewHeader(w http.ResponseWriter, headerName, value string)

SetNewHeader will expose and set the given headerName and value

SetNewHeader(w,"total","10") will set header "total" : "10"

func UnmarshalJSON

func UnmarshalJSON(request *http.Request, out interface{}) error

UnmarshalJSON parses data from request and return otherwise error return.

Types

type Parser

type Parser struct {
	Form url.Values
	// contains filtered or unexported fields
}

Parser helps in parsing the data from the URL params.

func NewParser

func NewParser(r *http.Request) *Parser

NewParser will call request.ParseForm() and create a new instance of parser.

func (*Parser) GetTenantID

func (p *Parser) GetTenantID() (uuid.UUID, error)

GetTenantID will get "tenantID" param in URL params.

func (*Parser) GetUUID

func (p *Parser) GetUUID(paramName string) (uuid.UUID, error)

GetUUID will get uuid from the given paramName in URL params.

func (*Parser) ParseLimitAndOffset

func (p *Parser) ParseLimitAndOffset() (limit, offset int)

ParseLimitAndOffset will parse limit and offset from query params.

Jump to

Keyboard shortcuts

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