Back to godoc.org

Package httputil

v0.7.0
Latest Go to latest

The highest tagged major version is .

Published: Dec 17, 2018 | License: MIT | Module: github.com/KyberNetwork/reserve-stats

Index

Constants

const (
	//PortFlag string for flag port
	PortFlag = "port"
)

func MiddlewareHandler

func MiddlewareHandler(c *gin.Context)

MiddlewareHandler handle middleware error

func NewHTTPAddressFromContext

func NewHTTPAddressFromContext(c *cli.Context) string

NewHTTPAddressFromContext returns the configured address to listen to from cli flags configuration.

func NewHTTPCliFlags

func NewHTTPCliFlags(defaultPort HTTPPort) []cli.Flag

NewHTTPCliFlags creates new cli flags for HTTP Server.

func ResponseFailure

func ResponseFailure(c *gin.Context, code int, err error)

ResponseFailure sets response code and error to the given one in parameter.

func RunHTTPTestCase

func RunHTTPTestCase(t *testing.T, tc HTTPTestCase, handler http.Handler)

RunHTTPTestCase run http request test case

func Sign

func Sign(r *http.Request, keyID, secret string) (*http.Request, error)

Sign sign a http request with selected header and return a signed request Use with http client only

type HTTPPort

type HTTPPort int

HTTPPort define custom type for port

const (
	// IPLocatorPort is port number of IpLocator service
	IPLocatorPort HTTPPort = 8001

	// UsersPort is the port number of Users service.
	UsersPort HTTPPort = 8002

	// ReserveRatesPort is the port number of Reserve Rates API.
	ReserveRatesPort HTTPPort = 8003

	// TradeLogsPort is the port number of TradeLogs service.
	TradeLogsPort HTTPPort = 8004

	// GatewayPort is the port number of API gateway service.
	GatewayPort HTTPPort = 8005

	// PriceAnalytic is the port number of Price Analytics API
	PriceAnalytic HTTPPort = 8006

	//AppName is the port number for Integration Address to AppName API
	AppName HTTPPort = 8007
)

type HTTPTestCase

type HTTPTestCase struct {
	Msg      string
	Endpoint string
	Method   string
	Params   map[string]string
	Body     []byte
	Assert   assertFn
}

HTTPTestCase struct for http test case

type TimeRangeQuery

type TimeRangeQuery struct {
	From uint64 `form:"from"`
	To   uint64 `form:"to"`
	// contains filtered or unexported fields
}

TimeRangeQuery is the common time range query parameters of reporting HTTP APIs. The time format is unix milliseconds.

func (*TimeRangeQuery) Validate

func (q *TimeRangeQuery) Validate(options ...TimeRangeQueryValidationOption) (time.Time, time.Time, error)

Validate validates the given time range query and converts them to native time.Time format if there is no error.

type TimeRangeQueryFreq

type TimeRangeQueryFreq struct {
	TimeRangeQuery
	Freq string `form:"freq"`
	// contains filtered or unexported fields
}

TimeRangeQueryFreq is the same as TimeRangeQuery with additional freq parameter.

func (*TimeRangeQueryFreq) Validate

func (q *TimeRangeQueryFreq) Validate(options ...TimeRangeQueryFreqValidationOption) (time.Time, time.Time, error)

Validate validates the given time range query based on given freq.

type TimeRangeQueryFreqValidationOption

type TimeRangeQueryFreqValidationOption func(q *TimeRangeQueryFreq)

TimeRangeQueryFreqValidationOption is the option to configure validation behaviour.

func TimeRangeQueryFreqWithValidFreqs

func TimeRangeQueryFreqWithValidFreqs(freqs map[string]time.Duration) TimeRangeQueryFreqValidationOption

TimeRangeQueryFreqWithValidFreqs configures the validation to use custom valid frequencies instead of the default one.

type TimeRangeQueryValidationOption

type TimeRangeQueryValidationOption func(q *TimeRangeQuery)

TimeRangeQueryValidationOption is the option to configure validation behaviour.

func TimeRangeQueryWithDefaultTimeFrame

func TimeRangeQueryWithDefaultTimeFrame(duration time.Duration) TimeRangeQueryValidationOption

TimeRangeQueryWithDefaultTimeFrame sets the given duration as the default time frame when doing validation.

func TimeRangeQueryWithMaxTimeFrame

func TimeRangeQueryWithMaxTimeFrame(duration time.Duration) TimeRangeQueryValidationOption

TimeRangeQueryWithMaxTimeFrame sets the given duration as the max time frame when doing validation.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier