NextNextSeason

This commit is contained in:
daru
2022-07-01 18:20:17 +02:00
parent fd84193d9d
commit f968c1b98e
5 changed files with 69 additions and 67 deletions

22
ober.go
View File

@@ -19,6 +19,7 @@ func RunWebserv() {
r.GET("/", Headers(Start))
r.GET("/api/season", Headers(Season))
r.GET("/api/nextseason", Headers(SeasonNext))
r.GET("/api/nextnextseason", Headers(SeasonNextNext))
r.GET("/api/auth/{user}", Headers(AuthTest))
r.GET("/api/anime/{id}", Headers(AnimeGet))
r.GET("/api/animesearch", Headers(AnimeSearchGet))
@@ -39,7 +40,7 @@ func RunWebserv() {
}
func Start(ctx *fasthttp.RequestCtx) {
season, err := GetSeasonCache(seasonApiJikan)
season, err := GetSeasonCache(GetCurrentSeasonString())
if err != nil {
addErrorToCtx(ctx, err)
return
@@ -77,7 +78,7 @@ func AuthTest(ctx *fasthttp.RequestCtx) {
}
func Season(ctx *fasthttp.RequestCtx) {
data, err := seasoncache.Get(seasonApiJikan)
data, err := seasoncache.Get(GetCurrentSeasonString())
if err != nil {
addErrorToCtx(ctx, err)
return
@@ -110,6 +111,23 @@ func SeasonNext(ctx *fasthttp.RequestCtx) {
ctx.SetStatusCode(fasthttp.StatusOK)
}
func SeasonNextNext(ctx *fasthttp.RequestCtx) {
data, err := seasoncache.Get(GetNextNextSeasonString())
if err != nil {
addErrorToCtx(ctx, err)
return
}
err = writeResponseBody(ctx, data)
if err != nil {
addErrorToCtx(ctx, err)
return
}
ctx.SetContentType("application/json; charset=utf-8")
ctx.SetStatusCode(fasthttp.StatusOK)
}
func AnimeGet(ctx *fasthttp.RequestCtx) {
idVal := ctx.UserValue("id")
if idVal == nil {