Documentation ¶
Index ¶
- Variables
- func AuthorizeRequest(next http.Handler) http.Handler
- func AuthorizeRequestWithNegroni(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- func DisplayAppError(w http.ResponseWriter, handlerError error, message string, code int)
- func GenerateJWT(name, role string) (string, error)
- func StartUp()
- func TokenFromAuthHeader(r *http.Request) (string, error)
- type AppClaims
- type DataStore
- type Level
Constants ¶
This section is empty.
Variables ¶
Package level variables, which are pointer to log.Logger.
var AppConfig configuration
AppConfig holds the configuration values from config.json file
Functions ¶
func AuthorizeRequest ¶
AuthorizeRequest Middleware validates JWT tokens from incoming HTTP requests.
func AuthorizeRequestWithNegroni ¶
func AuthorizeRequestWithNegroni(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
AuthorizeRequestWithNegroni is a Negroni Middleware that validates JWT tokens
func DisplayAppError ¶
func DisplayAppError(w http.ResponseWriter, handlerError error, message string, code int)
DisplayAppError provides app specific error in JSON
func GenerateJWT ¶
GenerateJWT generates a new JWT token for authenticated user.
Types ¶
type AppClaims ¶
type AppClaims struct { UserName string `json:"username"` Role string `json:"role"` jwt.StandardClaims }
AppClaims provides custom claim for JWT
type DataStore ¶
type DataStore struct {
MongoSession *mgo.Session
}
DataStore for MongoDB
func NewDataStore ¶
func NewDataStore() *DataStore
NewDataStore creates a new DataStore object to be used for each HTTP request.
func (*DataStore) Close ¶
func (ds *DataStore) Close()
Close closes a mgo.Session value. Used to add defer statements for closing the copied session.
func (*DataStore) Collection ¶
Collection returns mgo.collection for the given name