Documentation
¶
Index ¶
Constants ¶
View Source
const ( //AnyMethod should be passed when a handler wants to support any HTTP method. AnyMethod = "Any" //ReadinessEndpoint is the default URL for a readiness endpoint ReadinessEndpoint = "/readiness" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { ListenAddress string //Address in the format [host/ip]:port. Mandatory LogLevel string //INFO,FATAL,ERROR,WARN, DEBUG, TRACE Cors *CorsConfig //Optional cors config ReadinessCheck bool //Set to true to add a readiness handler at /readiness. Handlers []Handler //Array of handlers CertConfig *ServerCertificateConfig //Optional TLS configuration RateLimit *RateLimitConfig //Optional rate limiting config MiddlewareHandlers []MiddlewareHandler //Optional middleware handlers which will be run on every request Metrics bool //Optional. If true a prometheus metrics endpoint will be exposed at /metrics/ }
Config will hold the configuration of the service.
type CorsConfig ¶
type CorsConfig struct { Groups []string //Optional - which group(s) should the CORS config run on. Empty means the default route. Enabled bool //Whether CORS is enabled or not. OverrideCfg *cors.Config //Optional. This is only required if you do not want to use the default CORS configuration. }
CorsConfig specifies the CORS related config
type Handler ¶
type Handler struct { Method string //HTTP method or service.AnyMethod to support all limits. Path string //The path the endpoint runs on. Group string //Optional - specify a group if this is to have it's own group. N.B. The point of the group is to allow middleware to run on some requests and not others(based on the group). Handler func(c *gin.Context) //The handler to be used. }
Handler will hold all the callback handlers to be registered. N.B. gin will be used.
type MiddlewareHandler ¶
type MiddlewareHandler struct { Groups []string //Optional - what group should this middleware run on. Empty means the default route. Handler func(c *gin.Context) //The handler to be used. }
MiddlewareHandler will hold all the middleware and whether
type RateLimitConfig ¶
type RateLimitConfig struct { Groups []string //Optional - which group(s) should the rate limiting run on. Empty means the default route. Limit int //The number of requests allowed within the timeframe. Within int //The timeframe(seconds) the requests are allowed in. }
RateLimitConfig specifies the rate limiting config
type ServerCertificateConfig ¶
type ServerCertificateConfig struct { CertificateFile string //The TLS certificate file. KeyFile string //The TLS private key file. }
ServerCertificateConfig holds detail of the certificate config to be used
type Service ¶
type Service struct { *http.Server //Anonymous embedded struct to allow access to http server methods. // contains filtered or unexported fields }
Service will be the actual structure returned.
func NewService ¶
NewService will setup a new service based on the config and return this service.
Click to show internal directories.
Click to hide internal directories.