Documentation ¶
Index ¶
- Variables
- func AnswerHandler(w http.ResponseWriter, r *http.Request)
- func AuthHandler(w http.ResponseWriter, r *http.Request)
- func HomeHandler(w http.ResponseWriter, r *http.Request)
- func LeaderboardHandler(w http.ResponseWriter, r *http.Request)
- func MgoDBFromR(r *http.Request) models.DataLayer
- func MgoSessionFromCtx(ctx context.Context) models.Session
- func RobotsHandler(w http.ResponseWriter, r *http.Request)
- func ScoreHandler(w http.ResponseWriter, r *http.Request)
- func StaticHandler(w http.ResponseWriter, r *http.Request)
- func StatusHandler(w http.ResponseWriter, r *http.Request)
- type Answer
Constants ¶
This section is empty.
Variables ¶
var ErrJSONPayloadEmpty = errors.New("JSON payload is empty")
ErrJSONPayloadEmpty is returned when the JSON payload is empty.
var ErrJSONPayloadInvalidBody = errors.New("Cannot parse request body")
ErrJSONPayloadInvalidBody is returned when the JSON payload is fucked up.
var ErrJSONPayloadInvalidFormat = errors.New("Invalid JSON format")
ErrJSONPayloadInvalidFormat is returned when the JSON payload is fucked up.
Functions ¶
func AnswerHandler ¶
func AnswerHandler(w http.ResponseWriter, r *http.Request)
AnswerHandler handler receive the JSON answer for a question_id and return JSON containing a status (fail|success) AND if success a new question.
func AuthHandler ¶
func AuthHandler(w http.ResponseWriter, r *http.Request)
AuthHandler returns a JWT token.
func HomeHandler ¶
func HomeHandler(w http.ResponseWriter, r *http.Request)
HomeHandler returns the Homepage and the first question.
func LeaderboardHandler ¶
func LeaderboardHandler(w http.ResponseWriter, r *http.Request)
LeaderboardHandler returns the Leaderboard with top 10 scores.
func MgoDBFromR ¶
MgoDBFromR takes a request argument and return the extracted *mgo.session.
func MgoSessionFromCtx ¶
MgoSessionFromCtx takes a context argument and return the related *mgo.session.
func RobotsHandler ¶
func RobotsHandler(w http.ResponseWriter, r *http.Request)
RobotsHandler servers static files.
func ScoreHandler ¶
func ScoreHandler(w http.ResponseWriter, r *http.Request)
ScoreHandler stores scores from the request.
func StaticHandler ¶
func StaticHandler(w http.ResponseWriter, r *http.Request)
StaticHandler servers static files.
func StatusHandler ¶
func StatusHandler(w http.ResponseWriter, r *http.Request)
StatusHandler endpoint to acknowledge application status.