mirror of
https://github.com/ultrasn0w/huso.git
synced 2025-12-13 17:29:54 +01:00
GET animesearch
This commit is contained in:
23
ober.go
23
ober.go
@@ -17,6 +17,7 @@ func RunWebserv() {
|
||||
r.GET("/", Headers(Start))
|
||||
r.GET("/api/season", Headers(Season))
|
||||
r.GET("/api/anime/{id}", Headers(AnimeGet))
|
||||
r.GET("/api/animesearch/", Headers(AnimeSearchGet))
|
||||
r.GET("/api/user/{user?}", Headers(UserGet))
|
||||
r.GET("/api/watch/{user?}", Headers(WatchGet))
|
||||
r.GET("/api/watchext/{user?}", Headers(WatchExtendedGet))
|
||||
@@ -96,6 +97,28 @@ func AnimeGet(ctx *fasthttp.RequestCtx) {
|
||||
ctx.SetStatusCode(fasthttp.StatusOK)
|
||||
}
|
||||
|
||||
func AnimeSearchGet(ctx *fasthttp.RequestCtx) {
|
||||
if !ctx.QueryArgs().Has("q") || string(ctx.QueryArgs().Peek("q")) == "" {
|
||||
ctx.SetStatusCode(fasthttp.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
query := string(ctx.QueryArgs().Peek("q"))
|
||||
// Search with query
|
||||
_, bytes, err := SearchAnime(query)
|
||||
if err != nil {
|
||||
addErrorToCtx(ctx, err)
|
||||
return
|
||||
}
|
||||
_, err = ctx.Write(bytes)
|
||||
if err != nil {
|
||||
addErrorToCtx(ctx, err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.SetContentType("application/json; charset=utf-8")
|
||||
ctx.SetStatusCode(fasthttp.StatusOK)
|
||||
}
|
||||
|
||||
func UserGet(ctx *fasthttp.RequestCtx) {
|
||||
usrVal := ctx.UserValue("user")
|
||||
users := make([]User, 0)
|
||||
|
||||
Reference in New Issue
Block a user