handlers

package
v0.0.0-...-4998d35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2018 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrJSONPayloadEmpty = errors.New("JSON payload is empty")

ErrJSONPayloadEmpty is returned when the JSON payload is empty.

View Source
var ErrJSONPayloadInvalidBody = errors.New("Cannot parse request body")

ErrJSONPayloadInvalidBody is returned when the JSON payload is fucked up.

View Source
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

func MgoDBFromR(r *http.Request) models.DataLayer

MgoDBFromR takes a request argument and return the extracted *mgo.session.

func MgoSessionFromCtx

func MgoSessionFromCtx(ctx context.Context) models.Session

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.

Types

type Answer

type Answer struct {
	QID      int    `bson:"qid" json:"qid"`
	Regex    string `bson:"regex" json:"regex"`
	Modifier string `bson:"modifier" json:"modifier"`
}

Answer format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL