Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( RequestCounterVec = prometheus.NewCounterVec( prometheus.CounterOpts{ Namespace: "http", Subsystem: "requests", Name: "number_of_requests", Help: "Total number of requests handled by the API", }, []string{"endpoint", "method"}, ) )
RequestCounterVec counts total request per endpoint and method
View Source
var ( RequestDurationGauge = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Namespace: "http", Subsystem: "requests", Name: "request_duration", Help: "Avg time of requests handled by the API", }, []string{"endpoint", "method"}, ) )
RequestDurationGauge calculates avg time per endpoint and method
Functions ¶
func CorsHandler ¶
func CorsHandler(w http.ResponseWriter, r *http.Request)
CorsHandler swagger:route OPTIONS /
Handler to respond to CORS preflight requests ¶
Responses:
200: OK
Types ¶
type APIContext ¶
type APIContext struct { MongoClient mongo.Client DatabaseName string HandlerFunc http.HandlerFunc }
APIContext is the struct holds both Db Context and Handlers
func PrepareContext ¶
func PrepareContext() *APIContext
PrepareContext prepares the database connection, bundles it within an APIContext and returns it
func (*APIContext) Index ¶
func (apiContext *APIContext) Index(w http.ResponseWriter, r *http.Request)
Index swagger:route GET / Index
Handler to show welcome message.
Responses:
200: OK
func (*APIContext) Login ¶
func (apiContext *APIContext) Login(w http.ResponseWriter, r *http.Request)
Login swagger:route POST PUT /user Login
Handler to login the user, returns a JWT Token ¶
Responses:
200: OK 400: Bad Request 500: Internal Server Error
func (*APIContext) Refresh ¶
func (apiContext *APIContext) Refresh(w http.ResponseWriter, r *http.Request)
Refresh swagger:route POST PUT /login Refresh
Handler to refresh a JWT Token ¶
Responses:
200: OK 400: Bad Request 500: Internal Server Error
Click to show internal directories.
Click to hide internal directories.