示例#1
0
func AowQuote(ctx context.Context) error {
	index := randInt(len(quotes))
	quote := quotes[index]
	key := ctx.PathParams().Get("apiKey").Str()

	if valid := isKeyValid(key); valid == true {
		return goweb.API.RespondWithData(ctx, objx.MSI("quote", quote))
	}
	return goweb.API.RespondWithError(ctx, 400, "Access Denied: Invalid API Key")
}
示例#2
0
文件: accounts.go 项目: sporto/kic
func (c *Accounts) Adjust(ctx context.Context) (err error) {
	id := ctx.PathParams().Get("id").Str()

	getServ := &accounts.GetServ{}
	account, err := getServ.Run(c.DbSession, id)
	if err != nil {
		return goweb.API.RespondWithError(ctx, http.StatusNotFound, err.Error())
	}

	adjustServ := &account_balances.AdjustServ{}
	account, _, err = adjustServ.Run(c.DbSession, account)
	if err != nil {
		return goweb.API.RespondWithError(ctx, http.StatusInternalServerError, err.Error())
	}

	return goweb.API.RespondWithData(ctx, account)
}