httputil

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

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

Types

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

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

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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