mirror of
https://github.com/Penguin-71630/meme-bot-frontend-dc.git
synced 2026-03-12 20:40:16 +08:00
Refactor: cleanup
- Introduce tracing - Introduce cobra / viper framework - Introduce resty client - Seperate files in api/ and bot/ - Trim unused functions
This commit is contained in:
32
api/postGenLoginUrl.go
Normal file
32
api/postGenLoginUrl.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/Penguin-71630/meme-bot-frontend-dc/tracing"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type GenLoginURLRequest struct {
|
||||
UserId string `json:"userId"`
|
||||
}
|
||||
|
||||
type GenLoginURLResponse struct {
|
||||
LoginURL string `json:"loginUrl"`
|
||||
}
|
||||
|
||||
func (c *Client) PostGenLoginURL(
|
||||
userId string,
|
||||
) (string, error) {
|
||||
var res GenLoginURLResponse
|
||||
resp, err := c.client.R().
|
||||
SetBody(GenLoginURLRequest{UserId: userId}).
|
||||
Post("/auth/gen-login-url")
|
||||
if err != nil || resp.StatusCode() != http.StatusOK {
|
||||
tracing.Logger.Ctx(resp.Request.Context()).
|
||||
Error("failed to post gen-login-url",
|
||||
zap.Error(err))
|
||||
return "", ErrRequestFailed
|
||||
}
|
||||
return res.LoginURL, nil
|
||||
}
|
||||
Reference in New Issue
Block a user