Documentation
¶
Index ¶
- Variables
- func DisplayAppError(w http.ResponseWriter, handlerError error, message string, code int)
- func WithAuth(a Authorizer) negroni.Handler
- func WriteJson(w http.ResponseWriter, message string, data interface{}, code int)
- type AppClaims
- type AppResponse
- type Auth
- type Authorizer
- type Config
- type UserClaims
Constants ¶
This section is empty.
Variables ¶
View Source
var ( InvalidData = "Could not decode data" FetchError = "Could not fetch data" JwtHTTPError = "No valid JWT attached" )
Functions ¶
func DisplayAppError ¶
func DisplayAppError(w http.ResponseWriter, handlerError error, message string, code int)
Writes common errors, only displays message field back to the user
func WithAuth ¶
func WithAuth(a Authorizer) negroni.Handler
Middleware that makes sure each request has a valid JWT from this server.
Types ¶
type AppClaims ¶
type AppClaims struct {
UserClaims
jwt.StandardClaims
}
type AppResponse ¶
type AppResponse struct {
Message string `json:"message"`
Data interface{} `json:"data"`
}
type Auth ¶
type Auth struct {
Secret []byte
SigningMethod jwt.SigningMethod
}
Implements the Authorizer interface
type Authorizer ¶
type Config ¶
type Config struct {
Server string
MongoServer string
MongoUsername string
MongoPassword string
DbName string
JwtSecret []byte
}
var AppConfig *Config
Global for common package is the AppConfig
type UserClaims ¶
Used in middleware and attached to the context
Click to show internal directories.
Click to hide internal directories.