コード例 #1
0
ファイル: controllers.go プロジェクト: darthlukan/AOW-Server
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)
}