Documentation
¶
Index ¶
Constants ¶
View Source
const ( TOKEN_AUTH_TYPE_ACCESS = "access" TOKEN_AUTH_TYPE_REFRESH = "fresh" TOKEN_STORE_KEY_USERNAME = "username" TOKEN_STORE_KEY_UUID = "token_uuid" TOKEN_STORE_KEY_TYPE = "token_type" TOKEN_EXPIRES_ACCESS = time.Minute * 60 TOKEN_EXPIRTS_REFRESH = time.Hour * 24 * 7 )
View Source
const ( ROUTER_PREFIX = "/api/v1" ROUTER_USER = ROUTER_PREFIX + "/user/:action" ROUTER_APIKEY = ROUTER_PREFIX + "/key" ROUTER_STRATEGY = ROUTER_PREFIX + "/strategy/:type/:cmd" ROUTER_SHOW = ROUTER_PREFIX + "/show/:item" // for /user/:action USER_SIGNUP = "signup" USER_LOGIN = "login" USER_LOGOUT = "logout" USER_REFRESH = "refresh" USER_REQ_CODE = "reqcode" USER_SEND_CODE = "sendcode" // for /strategy/:type STRATEGY_TYPE_PERIOD = "period" STRATEGY_TYPE_GRIG = "grid" // for /strategy/:type/:cmd STRATEGY_CMD_START = "start" STRATEGY_CMD_STOP = "stop" // for /show/:item SHOW_STATUS = "status" SHOW_STRATEGY = "strategy" // unique ID of each strategy STRATEGY_UUID_LENGH = 36 // The signup/login state will expire if user doesn't request a code // after calling signup/login during USER_LOGIN_EXPIRATION USER_ACTION_EXPIRATION = time.Minute * 30 // The requested code will expire if user doesn't send the code // to server during USER_CODE_EXPIRATION USER_CODE_EXPIRATION = time.Minute * 30 )
Variables ¶
View Source
var ( SUCCESS = NewHttpResp("success", 0) ERR_INVALID_JSON = NewHttpResp("invalid JSON", -1) ERR_INVALID_TOKEN = NewHttpResp("invalid token", -20) ERR_GEN_TOKEN = NewHttpResp("token generation error", -21) ERR_INVALID_KEY = NewHttpResp("invalid API key", -30) ERR_NO_APIKEY = NewHttpResp("API key is not set", -31) ERR_INVALID_USER = NewHttpResp("user doesn't exist", -40) ERR_INVALID_PASSWORD = NewHttpResp("invalid password", -41) ERR_USER_ALREADY_EXISTS = NewHttpResp("user already exists", -42) ERR_USER_INVALID_ACTION = NewHttpResp("invalid action to request code", -43) ERR_USER_INVALID_CODE = NewHttpResp("invalid code", -44) ERR_INVALID_STRATEGY_INFO = NewHttpResp("invalid strategy info", -50) ERR_INVALID_STRATEGY_ID = NewHttpResp("invalid strategy ID", -51) ERR_INVALID_CONNECTION = NewHttpResp("invalid exchange connection", -60) ERR_INVALID_ROUTE = NewHttpResp("invalid route", -70) ERR_INVALID_DB_INSERT = NewHttpResp("internal DB insert error", -80) ERR_INVALID_DB_QUERY = NewHttpResp("internal DB query error", -81) ERR_SEND_SMS_INFO = NewHttpResp("invalid request for SMS", -90) )
Functions ¶
func Cors ¶
func Cors() gin.HandlerFunc
func HandleRequests ¶
func HandleRequests()
Types ¶
type HttpResp ¶
type HttpResp struct { Message interface{} `json:"message"` Code int32 `json:"code"` }
func NewHttpResp ¶
Click to show internal directories.
Click to hide internal directories.