Documentation ¶
Index ¶
- Variables
- func LogError(err error, context ...map[string]interface{}) bool
- func Login(handlerData HandlerData, w http.ResponseWriter, r *http.Request)
- func NewRouter(config *models.Config, db *gorm.DB) *mux.Router
- func Ping(handlerData HandlerData, w http.ResponseWriter, r *http.Request)
- func Register(handlerData HandlerData, w http.ResponseWriter, r *http.Request)
- func RouteHandler(requestType requestType, handlerData *HandlerData, inner RouteFunction, ...) http.Handler
- type AuthHandler
- type HTTPMethod
- type HandlerData
- type Route
- type RouteFunction
- type Routes
Constants ¶
This section is empty.
Variables ¶
View Source
var ( //ErrorTokenInvalid error if token is invalid ErrorTokenInvalid error = errors.New("Token invalid") //ErrorTokenEmpty error if token is empty ErrorTokenEmpty error = errors.New("Token empty") )
View Source
var AllowedSchemes = []string{"http", "https"}
AllowedSchemes schemes that are allowed in urls
Functions ¶
func Login ¶
func Login(handlerData HandlerData, w http.ResponseWriter, r *http.Request)
Login login handler -> /user/login
func Ping ¶
func Ping(handlerData HandlerData, w http.ResponseWriter, r *http.Request)
Ping handles ping request
func Register ¶
func Register(handlerData HandlerData, w http.ResponseWriter, r *http.Request)
Register register handler -> /user/create
func RouteHandler ¶
func RouteHandler(requestType requestType, handlerData *HandlerData, inner RouteFunction, name string) http.Handler
RouteHandler logs stuff
Types ¶
type AuthHandler ¶
AuthHandler handler for http auth
func NewAuthHandler ¶
func NewAuthHandler(request *http.Request) *AuthHandler
NewAuthHandler returns a new AuthHandler
func (AuthHandler) GetBearer ¶
func (authHandler AuthHandler) GetBearer() string
GetBearer return the bearer token
func (AuthHandler) IsInvalid ¶
func (authHandler AuthHandler) IsInvalid(err error) bool
IsInvalid return true if err is invalid
type HTTPMethod ¶
type HTTPMethod string
HTTPMethod http method. GET, POST, DELETE, HEADER, etc...
const ( GetMethod HTTPMethod = "GET" POSTMethod HTTPMethod = "POST" PUTMethod HTTPMethod = "PUT" DeleteMethod HTTPMethod = "DELETE" )
HTTP methods
type HandlerData ¶
HandlerData handlerData for web
type Route ¶
type Route struct { Name string Method HTTPMethod Pattern string HandlerFunc RouteFunction HandlerType requestType }
Route for REST
type RouteFunction ¶
type RouteFunction func(HandlerData, http.ResponseWriter, *http.Request)
RouteFunction function for handling a route
Click to show internal directories.
Click to hide internal directories.