httputils

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2020 License: Apache-2.0 Imports: 13 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRouterParam added in v1.5.0

func GetRouterParam(request *http.Request, paramName string) (string, error)

GetRouterParam retrieves parameter from URL like `/organization/{org_id}`

func GetRouterPositiveIntParam added in v1.5.0

func GetRouterPositiveIntParam(request *http.Request, paramName string) (uint64, error)

GetRouterPositiveIntParam retrieves parameter from URL like `/organization/{org_id}` and check it for being valid and positive integer, otherwise returns error

func LogRequest added in v1.3.0

func LogRequest(nextHandler http.Handler) http.Handler

LogRequest - middleware for logging requests

func MakeURLToEndpoint

func MakeURLToEndpoint(apiPrefix, endpoint string, args ...interface{}) string

MakeURLToEndpoint creates URL to endpoint, use constants from file endpoints.go

func MakeURLToEndpointMap added in v1.2.3

func MakeURLToEndpointMap(apiPrefix, endpoint string, args map[string]interface{}) string

MakeURLToEndpointMap creates URL to endpoint using arguments in map, use constants from file endpoints.go

func MakeURLToEndpointMapString added in v1.2.3

func MakeURLToEndpointMapString(apiPrefix, endpoint string, args map[string]string) string

MakeURLToEndpointMapString creates URL to endpoint using arguments in map in string format, use constants from file endpoints.go

func ReadClusterName

func ReadClusterName(writer http.ResponseWriter, request *http.Request) (types.ClusterName, bool)

ReadClusterName retrieves cluster name from request if it's not possible, it writes http error to the writer and returns false

func ReadClusterNames added in v1.5.0

func ReadClusterNames(writer http.ResponseWriter, request *http.Request) ([]types.ClusterName, bool)

ReadClusterNames does the same as `readClusterName`, except for multiple clusters.

func ReadErrorKey added in v1.4.1

func ReadErrorKey(writer http.ResponseWriter, request *http.Request) (types.ErrorKey, bool)

ReadErrorKey retrieves error key from request's url or writes an error to writer. The function returns an error key and a bool indicating if it was successful.

func ReadOrganization added in v1.5.0

func ReadOrganization(writer http.ResponseWriter, request *http.Request, auth bool) (types.OrgID, bool)

ReadOrganization retrieves organization id from request if it's not possible, it writes http error to the writer and returns false

func ReadOrganizations added in v1.5.0

func ReadOrganizations(writer http.ResponseWriter, request *http.Request) ([]types.OrgID, bool)

ReadOrganizations does the same as `readOrganizationID`, except for multiple organizations.

func ReadRuleID added in v1.4.1

func ReadRuleID(writer http.ResponseWriter, request *http.Request) (types.RuleID, bool)

ReadRuleID retrieves rule id from request's url or writes an error to writer. The function returns a rule id and a bool indicating if it was successful.

func ReplaceParamsInEndpointAndTrimLeftSlash

func ReplaceParamsInEndpointAndTrimLeftSlash(endpoint, replacer string) string

ReplaceParamsInEndpointAndTrimLeftSlash replaces params in endpoint and trims left slash

Types

This section is empty.

Jump to

Keyboard shortcuts

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