utils

package
v0.0.0-...-9bd2c4f Latest Latest
Warning

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

Go to latest
Published: May 15, 2018 License: BSD-3-Clause Imports: 16 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Adapt

func Adapt(h http.Handler, adapters ...Adapter) http.Handler

func AdaptHTTPWithHeader

func AdaptHTTPWithHeader(w http.ResponseWriter,
	header constants.Header) http.ResponseWriter

func AdaptHTTPWithStatus

func AdaptHTTPWithStatus(w http.ResponseWriter,
	header int) http.ResponseWriter

make sure AdaptHTTPWithStatus is lastly added to the response writer, otherwise it would not work (ref: https://golang.org/pkg/net/http/#ResponseWriter)

func AdaptLimiter

func AdaptLimiter(lim *rate.Limiter, f func(w http.ResponseWriter, r *http.Request)) func(w http.ResponseWriter, r *http.Request)

AdaptLimiter adapts the HTTP handler f to a limited handler that allows events up to rate lr and permits bursts of at most lb tokens.

func AdaptRouterToDebugMode

func AdaptRouterToDebugMode(router *mux.Router) *mux.Router

func AdaptStatsHits

func AdaptStatsHits(f func(w http.ResponseWriter, r *http.Request)) func(w http.ResponseWriter, r *http.Request)

func AdaptStatsRouteHits

func AdaptStatsRouteHits(route string, f func(w http.ResponseWriter, r *http.Request)) func(w http.ResponseWriter, r *http.Request)

func GetLocalIP

func GetLocalIP() string

func GetPort

func GetPort() int32

func Map

func Map(m interface{}) map[string]interface{}

func MapToExposureAddress

func MapToExposureAddress(in string) string

func RandStringBytesMaskImprSrc

func RandStringBytesMaskImprSrc(n int) string

func ReflectFuncName

func ReflectFuncName(fun interface{}) string

func SortArrayInt

func SortArrayInt(origin []int)

func SortArrayIntReverse

func SortArrayIntReverse(origin []int)

func StripRouteToAPIRoute

func StripRouteToAPIRoute(rt string) string

func StripRouteToFunctName

func StripRouteToFunctName(rt string) string

Types

type Adapter

type Adapter func(http.Handler) http.Handler

func Logging

func Logging(l *log.Logger) Adapter

func RecoverHandler

func RecoverHandler() Adapter

func SupportXHTTPMethodOverride

func SupportXHTTPMethodOverride() Adapter

Override method by checking its header One thing you can do is to "tunnel" HTTP Methods inside another HTTP Header. Basically you have a header that says "No, seriously, I know I got here via a POST, but use this one instead." You would still POST, but then you'd have "X-HTTP-Method-Override:PUT" as a header.

func WithHeader

func WithHeader(key, value string) Adapter

Jump to

Keyboard shortcuts

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