Documentation
¶
Index ¶
- Constants
- func CreateToken(username string, config *config.HTTPConfig) (string, error)
- func Index(w http.ResponseWriter, r *http.Request)
- func ReturnAccessControlAllowOrigin(cors map[string]bool, checkURL string) (string, error)
- type BaseHandler
- type GetEvents
- type GetEventsRequest
- type GetEventsResponse
- type PostLogin
- type PostLoginRequest
- type PostLoginResponse
- type PostLoginResponseData
- type PostSignup
- type PostSignupRequest
- type PostSignupResponse
- type PostSignupResponseData
- type PostUser
- type PostUserRequest
- type PostUserResponse
- type PrometheusHandler
- type ReqContext
Constants ¶
const ( CategoryAuth = "Auth" CategoryEvent = "Event" CategoryUser = "User" )
Categories for handlers
Variables ¶
This section is empty.
Functions ¶
func CreateToken ¶ added in v1.1.0
func CreateToken(username string, config *config.HTTPConfig) (string, error)
func ReturnAccessControlAllowOrigin ¶ added in v1.1.0
ReturnAccessControlAllowOrigin returns the appropriate Access-Control-Allow-Origin based on a map of acceptable domains TODO: Account for when the origin is not passed in
Types ¶
type BaseHandler ¶
type BaseHandler struct {
http.Handler
Name string
Category string
DB *gorm.DB
CORS map[string]bool
Config *config.HTTPConfig
}
BaseHandler This is the base handler all the handlers extend
func NewBaseHandler ¶
func NewBaseHandler(db *gorm.DB, cors map[string]bool) BaseHandler
func (*BaseHandler) WriteResponse ¶
func (b *BaseHandler) WriteResponse(w http.ResponseWriter, reqCtx *ReqContext)
type GetEvents ¶
type GetEvents struct {
BaseHandler
}
type GetEventsRequest ¶
type GetEventsRequest struct {
Limit int `json:"limit" yaml:"limit"`
}
type GetEventsResponse ¶
type PostLogin ¶ added in v1.1.0
type PostLogin struct {
BaseHandler
}
PostLogin post login handler object
type PostLoginRequest ¶ added in v1.1.0
type PostLoginRequest struct {
Username string `json:"username" yaml:"username"`
Password string `json:"password" yaml:"password"`
}
PostLoginRequest login request object
type PostLoginResponse ¶ added in v1.1.0
type PostLoginResponse struct {
Status int `json:"status" yaml:"status"`
Data PostLoginResponseData `json:"data" yaml:"data"`
}
type PostLoginResponseData ¶ added in v1.1.0
type PostLoginResponseData struct {
Username string `json:"username" yaml:"username"`
Token string `json:"token" yaml:"token"`
}
PostLoginResponseData login request response object
type PostSignup ¶ added in v1.1.0
type PostSignup struct {
BaseHandler
}
func (PostSignup) ServeHTTP ¶ added in v1.1.0
func (h PostSignup) ServeHTTP(w http.ResponseWriter, r *http.Request)
type PostSignupRequest ¶ added in v1.1.0
type PostSignupResponse ¶ added in v1.1.0
type PostSignupResponse struct {
Status int `json:"status" yaml:"status"`
Data PostSignupResponseData `json:"data" yaml:"data"`
}
type PostSignupResponseData ¶ added in v1.1.0
type PostUser ¶ added in v1.1.0
type PostUser struct {
BaseHandler
}
type PostUserRequest ¶ added in v1.1.0
type PostUserRequest struct {
Username string `json:"username" yaml:"username"`
}
type PostUserResponse ¶ added in v1.1.0
type PrometheusHandler ¶
type PrometheusHandler struct {
Path string
Handle http.HandlerFunc
Metrics *metrics.Metrics
}
Handler is an HTTP handle for serving metric data
func NewPrometheusHandler ¶
func NewPrometheusHandler() *PrometheusHandler
New is a factory function creating a new Metrics instance