Something went wrong. Try again.
My amazing website
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354package api
import ( "net/http"
"github.com/labstack/echo/v4" "isabelroses.com/lib")
func Github(c echo.Context) error { g := new(lib.GitHubDono)
if err := c.Bind(g); err != nil { return echo.NewHTTPError(http.StatusBadRequest, err.Error()) }
if g.Sponsorship.PrivaryLevel == "SECRET" { return c.String(http.StatusOK, "Accepted, and hidden") }
if g.Action != "created" { return c.String(http.StatusOK, "Not a new sponsorship") }
var newData map[string]interface{} switch { case g.Sponsorship.Tier.IsOneTime: newData = map[string]interface{}{ "tier": "OneTime", "name": getName(g.Sponsorship.Sponsor), "url": g.Sponsorship.Sponsor.HTMLURL, "avatar": g.Sponsorship.Sponsor.AvatarURL, } case !g.Sponsorship.Tier.IsOneTime: newData = map[string]interface{}{ "tier": g.Sponsorship.Tier.Name, "name": getName(g.Sponsorship.Sponsor), "url": g.Sponsorship.Sponsor.HTMLURL, "avatar": g.Sponsorship.Sponsor.AvatarURL, } }
lib.AppendToDonos(newData)
return c.JSON(http.StatusOK, g)}
func getName(sponsor lib.GitHubSponsor) string { if sponsor.Name != "" { return sponsor.Name } return sponsor.Login}