Documentation ¶
Index ¶
- Variables
- func ExpiresAt(ctx context.Context) (int64, error)
- func User(ctx context.Context) (string, error)
- type API
- func (a *API) AttachModuleDelete(path string, f func(http.ResponseWriter, *http.Request))
- func (a *API) AttachModuleGet(path string, f func(http.ResponseWriter, *http.Request))
- func (a *API) AttachModulePost(path string, f func(http.ResponseWriter, *http.Request))
- func (a *API) AttachModulePut(path string, f func(http.ResponseWriter, *http.Request))
- func (a *API) Init() error
- func (a *API) InitJWT() error
- func (a *API) ProtectedAttachModuleDelete(path string, f func(http.ResponseWriter, *http.Request))
- func (a *API) ProtectedAttachModuleGet(path string, f func(http.ResponseWriter, *http.Request))
- func (a *API) ProtectedAttachModulePost(path string, f func(http.ResponseWriter, *http.Request))
- func (a *API) ProtectedAttachModulePut(path string, f func(http.ResponseWriter, *http.Request))
- func (a *API) Run(ctx context.Context) error
- func (a *API) ValidateJWTMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- type Claims
- type Credentials
Constants ¶
This section is empty.
Variables ¶
var ErrNoUser = errors.New("No user stored in context")
ErrNotFound is returned when no data could be found
Functions ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API represents a Rest API instance
func (*API) AttachModuleDelete ¶
AttachModuleDelete registers a new DELETE handler for the API
func (*API) AttachModuleGet ¶
AttachModuleGet registers a new GET handler for the API
func (*API) AttachModulePost ¶
AttachModulePost registers a new POST handler for the API
func (*API) AttachModulePut ¶
AttachModulePut registers a new PUT handler for the API
func (*API) ProtectedAttachModuleDelete ¶
ProtectedAttachModuleDelete registers a new GET handler for the API (needs valid authentication token)
func (*API) ProtectedAttachModuleGet ¶
ProtectedAttachModuleGet registers a new GET handler for the API (needs valid authentication token)
func (*API) ProtectedAttachModulePost ¶
ProtectedAttachModulePost registers a new GET handler for the API (needs valid authentication token)
func (*API) ProtectedAttachModulePut ¶
ProtectedAttachModulePut registers a new GET handler for the API (needs valid authentication token)
func (*API) ValidateJWTMiddleware ¶
func (a *API) ValidateJWTMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
ValidateJWTMiddleware is used to validate a JWT token
type Claims ¶
type Claims struct { // TODO: Maybe it is not a good idea to use the username itself in jwt Claim Username string `json:"username"` jwt.StandardClaims }
Claims contains all the content stored in the JWT token
type Credentials ¶
Credentials is a struct that models the structure of a user, both in the request body, and in the DB