Documentation ¶
Index ¶
- Variables
- func GenLoginRoute(serve func(writer http.ResponseWriter), ...) func(http.ResponseWriter, *http.Request)
- func GenLoginWall(ifNotAuthed func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request) bool
- func GenSignupRoute(serve func(http.ResponseWriter), getSignupData func(*http.Request) SignupData, ...) func(writer http.ResponseWriter, r *http.Request)
- func SetURI(uri string)
- type LoginData
- type SignupData
- type Token
- type User
- type UserDataHandle
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func GenLoginRoute ¶
func GenLoginRoute(serve func(writer http.ResponseWriter), getLoginData func(*http.Request) LoginData, afterAuthed func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)
Generates a login route to be given as the http handler for the /login route.
func GenLoginWall ¶
func GenLoginWall(ifNotAuthed func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request) bool
Generates a login wall that blocks entrance to the route. It also saves some visit-related metric data and saves it with a granularity level of 1 (meaning day-level granularity). The metric custodian gradually reduces the granularity - for example, every month, the previous month's day-level data will be scrapped for the month level data.
func GenSignupRoute ¶
func GenSignupRoute(serve func(http.ResponseWriter), getSignupData func(*http.Request) SignupData, successfullyCreated func(http.ResponseWriter, *http.Request)) func(writer http.ResponseWriter, r *http.Request)
Generates a signup route to be used as the http handler for the /signup route
Types ¶
type LoginData ¶
type LoginData struct { // The username provided to the login route. Username string // The password provided to the login route. This password is only used to generate the token for authentication, then is deleted. Password string }
The encapsulator for the login data returned by the getLoginData parameter function for GenLoginRoute. This data is typically from a form.
type SignupData ¶
type SignupData struct { // The username provided to the signup route. Username string // The password provided to the signup route. This password is only used to generate the token for authentication. Password string }
The encapsulator for the signup data returned by the getSignupData parameter function for GenSignupRoute. This data is typically from a form.
type Token ¶
type Token struct { /* The token, which will be a SHA256 sum of the username and password concatenated. */ Token string `json:"token"` }
The struct representing the token.
type User ¶
type User struct { // Username of the user. Username string `json:"username"` // User token (generated by the GenToken function). Token string `json:"token"` }
Model of a user.
type UserDataHandle ¶
type UserDataHandle struct {
// contains filtered or unexported fields
}
func NewDataHandle ¶
func NewDataHandle(filter bson.D) UserDataHandle
func (*UserDataHandle) GetDataHandle ¶
func (u *UserDataHandle) GetDataHandle() *map[string]interface{}
func (*UserDataHandle) Push ¶
func (u *UserDataHandle) Push()