mirror of
https://github.com/ultrasn0w/huso.git
synced 2025-12-13 17:29:54 +01:00
Next season feature
This commit is contained in:
20
ober.go
20
ober.go
@@ -16,6 +16,7 @@ func RunWebserv() {
|
||||
r := router.New()
|
||||
r.GET("/", Headers(Start))
|
||||
r.GET("/api/season", Headers(Season))
|
||||
r.GET("/api/nextseason", Headers(SeasonNext))
|
||||
r.GET("/api/auth/{user}", Headers(AuthTest))
|
||||
r.GET("/api/anime/{id}", Headers(AnimeGet))
|
||||
r.GET("/api/animesearch", Headers(AnimeSearchGet))
|
||||
@@ -34,7 +35,7 @@ func RunWebserv() {
|
||||
}
|
||||
|
||||
func Start(ctx *fasthttp.RequestCtx) {
|
||||
season, err := GetSeasonCache()
|
||||
season, err := GetSeasonCache(seasonApiJikan)
|
||||
if err != nil {
|
||||
addErrorToCtx(ctx, err)
|
||||
return
|
||||
@@ -78,6 +79,23 @@ func Season(ctx *fasthttp.RequestCtx) {
|
||||
ctx.SetStatusCode(fasthttp.StatusOK)
|
||||
}
|
||||
|
||||
func SeasonNext(ctx *fasthttp.RequestCtx) {
|
||||
data, err := seasoncache.Get(GetNextSeasonString())
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user