Added redirects for other list services
This commit is contained in:
24
pages/anime/redirect.go
Normal file
24
pages/anime/redirect.go
Normal file
@ -0,0 +1,24 @@
|
||||
package anime
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// RedirectByMapping redirects to the anime with the given mapping ID.
|
||||
func RedirectByMapping(mappingName string) func(*aero.Context) string {
|
||||
return func(ctx *aero.Context) string {
|
||||
id := ctx.Get("id")
|
||||
finder := arn.NewAnimeFinder(mappingName)
|
||||
anime := finder.GetAnime(id)
|
||||
|
||||
if anime == nil {
|
||||
return ctx.Error(http.StatusNotFound, "Anime not found", nil)
|
||||
}
|
||||
|
||||
return utils.SmartRedirect(ctx, "/anime/"+anime.ID)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user