handlers

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2021 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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 Index

func Index(w http.ResponseWriter, r *http.Request)

func ReturnAccessControlAllowOrigin added in v1.1.0

func ReturnAccessControlAllowOrigin(cors map[string]bool, checkURL string) (string, error)

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
}

func (GetEvents) ServeHTTP

func (h GetEvents) ServeHTTP(w http.ResponseWriter, r *http.Request)

type GetEventsRequest

type GetEventsRequest struct {
	Limit int `json:"limit" yaml:"limit"`
}

type GetEventsResponse

type GetEventsResponse struct {
	Status int            `json:"status" yaml:"status"`
	Data   []models.Event `json:"data" yaml:"data"`
}

type PostLogin added in v1.1.0

type PostLogin struct {
	BaseHandler
}

PostLogin post login handler object

func (PostLogin) ServeHTTP added in v1.1.0

func (h PostLogin) ServeHTTP(w http.ResponseWriter, r *http.Request)

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 PostSignupRequest struct {
	Username string `json:"username" yaml:"username"`
	Password string `json:"password" yaml:"password"`
}

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 PostSignupResponseData struct {
	Username string `json:"username" yaml:"username"`
	Token    string `json:"token" yaml:"token"`
}

type PostUser added in v1.1.0

type PostUser struct {
	BaseHandler
}

func (PostUser) ServeHTTP added in v1.1.0

func (h PostUser) ServeHTTP(w http.ResponseWriter, r *http.Request)

type PostUserRequest added in v1.1.0

type PostUserRequest struct {
	Username string `json:"username" yaml:"username"`
}

type PostUserResponse added in v1.1.0

type PostUserResponse struct {
	Status int           `json:"status" yaml:"status"`
	Data   []models.User `json:"data" yaml:"data"`
}

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

type ReqContext

type ReqContext struct {
	ErrorCode   string `json:"errorCode"`
	ErrorDetail string `json:"errorDetail"`

	HTTPStatusCode int `json:"httpStatus"`
	// Reply can be any type convertible to valid JSON
	HTTPReply interface{}
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL