Documentation ¶
Index ¶
- func Cors(next http.Handler) http.Handler
- func GZIPCompress(next http.Handler) http.Handler
- func LogFormatter(next http.Handler) http.Handler
- func Recover(next http.Handler) http.Handler
- func Secure(next http.Handler) http.Handler
- type Auth
- type GZIPReponseWriter
- type MetricsHandler
- type RateLimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GZIPCompress ¶
GZIPCompress checks if the request accepts encoding and utilized gzip or proceed without compressing.
func LogFormatter ¶
LogFormatter prints the server requests on the console.
Types ¶
type Auth ¶
Auth contains the elements needed to authorize users.
func (*Auth) AdminsOnly ¶
AdminsOnly requires the user to be an administrator to proceed.
type GZIPReponseWriter ¶
type GZIPReponseWriter struct {
// contains filtered or unexported fields
}
GZIPReponseWriter is a response writer containing a GZIP writer in it
func NewGZIPResponseWriter ¶
func NewGZIPResponseWriter(rw http.ResponseWriter) *GZIPReponseWriter
NewGZIPResponseWriter returns a new GZIPResponseWriter.
func (*GZIPReponseWriter) Flush ¶
func (g *GZIPReponseWriter) Flush()
Flush flushes any pending compressed data and closes the gzip writer.
func (*GZIPReponseWriter) Header ¶
func (g *GZIPReponseWriter) Header() http.Header
Header is implemented to satisfy the response writer interface.
func (*GZIPReponseWriter) Write ¶
func (g *GZIPReponseWriter) Write(d []byte) (int, error)
Write is implemented to satisfy the response writer interface.
func (*GZIPReponseWriter) WriteHeader ¶
func (g *GZIPReponseWriter) WriteHeader(statuscode int)
WriteHeader is implemented to satisfy the response writer interface.
type MetricsHandler ¶
type MetricsHandler struct {
// contains filtered or unexported fields
}
MetricsHandler implements a scrapper middleware.
func NewMetrics ¶
func NewMetrics() MetricsHandler
NewMetrics initializes the metrics and returns the handler used to scrap.
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter uses a leaky bucket algorithm for limiting the requests to the API from the same host.
func NewRateLimiter ¶
func NewRateLimiter(config config.RateLimiter, rdb *redis.Client) *RateLimiter
NewRateLimiter returns a rate limiter with the configuration values passed.