Documentation ¶
Index ¶
- func AdminHandler() gin.HandlerFunc
- func ChangeSettings(c *gin.Context)
- func Connect(c *gin.Context)
- func Depart(c *gin.Context)
- func Extend(c *gin.Context)
- func GameMap(c *gin.Context)
- func GameStatus(c *gin.Context)
- func GitHub(c *gin.Context)
- func GitHubCallback(c *gin.Context)
- func Google(c *gin.Context)
- func GoogleCallback(c *gin.Context)
- func InitController(c *config.Config, a *auth.Auther)
- func JWTHandler() gin.HandlerFunc
- func Login(c *gin.Context)
- func MaintenanceHandler() gin.HandlerFunc
- func ModelHandler() gin.HandlerFunc
- func Players(c *gin.Context)
- func PurgeUserData(c *gin.Context)
- func Register(c *gin.Context)
- func RemoveRailNode(c *gin.Context)
- func Settings(c *gin.Context)
- func SignOut(c *gin.Context)
- func StartGame(c *gin.Context)
- func StopGame(c *gin.Context)
- func Twitter(c *gin.Context)
- func TwitterCallback(c *gin.Context)
- type DefaultValidator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdminHandler ¶
func AdminHandler() gin.HandlerFunc
AdminHandler handles admin action It should be called after JWTHandler is called
func ChangeSettings ¶
ChangeSettings returns the result of change profile @Description change user attributes including private one @Tags changeSettingsResponse @Summary change user attributes @Accept json @Produce json @Param Authorization header string true "with the bearer started" @Param resname path string true "changing resource name" Enums(custom_name, use_cname) @Param value body string true "changing resource value" @Success 200 {object} changeSettingsResponse "changed user attributes" @Failure 400 {object} errInfo "invalid parameter" @Failure 401 {object} errInfo "invalid jwt" @Failure 503 {object} errInfo "under maintenance" @Router /settings/{resname} [post]
func Connect ¶
Connect returns result of rail connection @Description result of rail node connection @Tags connectResponse @Summary connect @Accept json @Produce json @Param x body number true "x coordinate" @Param y body number true "y coordinate" @Param scale body number true "width,height(100%)=2^scale" @Param from body integer true "from rail node id" @Param to body integer true "to rail node id" @Success 200 {object} connectResponse "connect rail node" @Failure 400 {object} errInfo "reason of fail" @Failure 401 {object} errInfo "invalid jwt" @Failure 503 {object} errInfo "under maintenance" @Router /rail_nodes/connect [post]
func Depart ¶
Depart returns result of rail node creation @Description result of rail node creation @Tags deptResponse @Summary depart @Accept json @Produce json @Param x body number true "x coordinate" @Param y body number true "y coordinate" @Param scale body number true "width,height(100%)=2^scale" @Success 200 {object} deptResponse "created rail node" @Failure 400 {object} errInfo "reason of fail" @Failure 401 {object} errInfo "invalid jwt" @Failure 503 {object} errInfo "under maintenance" @Router /rail_nodes [post]
func Extend ¶
Extend returns result of rail node extension @Description result of rail node extension @Tags extendResponse @Summary extend @Accept json @Produce json @Param x body number true "x coordinate" @Param y body number true "y coordinate" @Param scale body number true "width,height(100%)=2^scale" @Param rnid body integer true "tail rail node id" @Success 200 {object} extendResponse "extend rail node" @Failure 400 {object} errInfo "reason of fail" @Failure 401 {object} errInfo "invalid jwt" @Failure 503 {object} errInfo "under maintenance" @Router /rail_nodes/extend [post]
func GameMap ¶
GameMap returns all data of gamemap @Description entities are delegate object @Tags entities.DelegateMap @Summary get all entities in specified area @Accept json @Produce json @Param cx query number true "x coordinate" @Param cy query number true "y coordinate" @Param scale query number true "width,height(100%)=2^scale" @Param delegate query number true "width,height(grid)=2^delegate" @Success 200 {object} entities.DelegateMap "map centered (x,y) with grid in (width,height)" @Failure 400 {array} string "reasons of error when cx, cy and scale are out of area" @Router /gamemap [get]
func GameStatus ¶
GameStatus returns game status @Description game status @Tags gameStatus @Summary game status @Produce json @Success 200 {object} gameStatus "game status" @Router /game [get]
func GitHubCallback ¶
GitHubCallback registers user info @Description try register github info @Summary try register github info @Param state query string true "state" @Param code query string true "code" @Failure 503 {string} string "no OAuth token"
func GoogleCallback ¶
GoogleCallback registers user info @Param state query string true "state" @Param code query string true "code" @Failure 503 {string} string "no OAuth token"
func InitController ¶
InitController loads config
func JWTHandler ¶
func JWTHandler() gin.HandlerFunc
JWTHandler handles user action with jwt key It should be called after MaintenanceHandler is called
func Login ¶
Login returns result of password login @Description try login using loginid/password paramter @Tags jwtInfo @Summary try login to RushHour server @Accept json @Produce json @Param id body string true "email address" @Param password body string true "password" @Success 200 {object} jwtInfo "json web token containing user attributes" @Failure 400 {object} errInfo "reasons of error when login fail" @Failure 503 {object} errInfo "under maintenance (apply only normal, except admin)" @Router /login [post]
func MaintenanceHandler ¶
func MaintenanceHandler() gin.HandlerFunc
MaintenanceHandler blocks user access under maintenance
func ModelHandler ¶
func ModelHandler() gin.HandlerFunc
ModelHandler handles model and error controling It causes panic when neither result keyOk or keyErr is set It should be called after JWTHandeler and AdminHandler are called
func Players ¶
Players returns list of player @Description list of player @Tags []entities.Player @Summary list of player @Accept json @Produce json @Success 200 {array} entities.Player "list of player" @Failure 503 {object} errInfo "under maintenance" @Router /players [get]
func PurgeUserData ¶
PurgeUserData deletes all user data @Description result of purging @Tags gameStatus @Summary start game @Produce json @Success 200 {object} gameStatus "game status" @Failure 400 {object} errInfo "reason of fail" @Failure 401 {object} errInfo "invalid jwt" @Router /admin/game/purge [post]
func Register ¶
Register returns result of password sign up @Description try register with loginid/password @Tags jwtInfo @Summary try register to RushHour server @Accept json @Produce json @Param id body string true "email address" @Param password body string true "password" @Param name body string false "display name" @Param hue body integer true "player's rail line symbol color (HSV model)" @Success 200 {object} jwtInfo "json web token containing user attributes" @Failure 400 {object} errInfo "reasons of error when register" @Failure 503 {object} errInfo "under maintenance" @Router /register [post]
func RemoveRailNode ¶
RemoveRailNode returns result of rail deletion @Description result of rail node deletion @Tags removeRailNodeResponse @Summary remove rail node @Accept json @Produce json @Param rnid body integer true "rail node id" @Success 200 {object} removeRailNodeResponse "connect rail node" @Success 400 {object} errInfo "reason of fail" @Failure 401 {object} errInfo "invalid jwt" @Failure 503 {object} errInfo "under maintenance" @Router /rail_nodes [delete]
func Settings ¶
Settings returns the list of customizable attributes @Description list up user attributes including private one @Tags services.AccountSettings @Summary get user attributes @Accept json @Produce json @Param Authorization header string true "with the bearer started" @Success 200 {object} services.AccountSettings "user attributes" @Failure 400 {object} errInfo "under maintenance" @Failure 401 {object} errInfo "invalid jwt" @Failure 503 {object} errInfo "under maintenance" @Router /settings [get]
func SignOut ¶
SignOut deletes cached OAuth token. @Description deletes OAuth token @Summary execute user sign out @Accept json @Produce json @Success 200 {object} string "sign out successfully" @Failure 401 {object} errInfo "invalid jwt" @Failure 503 {object} errInfo "under maintenance" @Router /signout [get]
func StartGame ¶
StartGame returns result of game starting @Description result of game starting @Tags gameStatus @Summary start game @Produce json @Success 200 {object} gameStatus "game status" @Failure 400 {object} errInfo "reason of fail" @Failure 401 {object} errInfo "invalid jwt" @Router /admin/game/start [post]
func StopGame ¶
StopGame returns result of game stopping @Description result of game stopping @Tags gameStatus @Summary stop game @Produce json @Success 200 {object} gameStatus "game status" @Failure 400 {object} errInfo "reason of fail" @Failure 401 {object} errInfo "invalid jwt" @Router /admin/game/stop [post]
func TwitterCallback ¶
TwitterCallback registers user info @Param oauth_verifier query string true "access token" @Failure 503 {string} string "session expire" @Failure 503 {string} string "no OAuth token"
Types ¶
type DefaultValidator ¶
type DefaultValidator struct {
// contains filtered or unexported fields
}
DefaultValidator enables custom validation
func (*DefaultValidator) Engine ¶
func (v *DefaultValidator) Engine() interface{}
Engine is implementation of binding.StructValidator
func (*DefaultValidator) ValidateStruct ¶
func (v *DefaultValidator) ValidateStruct(obj interface{}) error
ValidateStruct is implementation of binding.StructValidator