Documentation ¶
Index ¶
- Constants
- func MiddlewareHandler(c *gin.Context)
- func NewHTTPAddressFromContext(c *cli.Context) string
- func NewHTTPCliFlags(defaultPort HTTPPort) []cli.Flag
- func ResponseFailure(c *gin.Context, code int, err error)
- func RunHTTPTestCase(t *testing.T, tc HTTPTestCase, handler http.Handler)
- func Sign(r *http.Request, keyID, secret string) (*http.Request, error)
- type HTTPPort
- type HTTPTestCase
- type TimeRangeQuery
- type TimeRangeQueryFreq
- type TimeRangeQueryFreqValidationOption
- type TimeRangeQueryValidationOption
Constants ¶
const (
//PortFlag string for flag port
PortFlag = "port"
)
Variables ¶
This section is empty.
Functions ¶
func MiddlewareHandler ¶
MiddlewareHandler handle middleware error
func NewHTTPAddressFromContext ¶
NewHTTPAddressFromContext returns the configured address to listen to from cli flags configuration.
func NewHTTPCliFlags ¶
NewHTTPCliFlags creates new cli flags for HTTP Server.
func ResponseFailure ¶
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
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 ¶
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.