diff --git a/assets.go b/assets.go index d89c7db1..ef4656a0 100644 --- a/assets.go +++ b/assets.go @@ -4,6 +4,8 @@ import ( "io/ioutil" "github.com/aerogo/aero" + "github.com/aerogo/sitemap" + "github.com/animenotifier/arn" "github.com/animenotifier/notify.moe/components/js" ) @@ -52,6 +54,42 @@ func configureAssets(app *aero.Application) { return ctx.File("videos" + ctx.Get("file")) }) + // Anime sitemap + app.Get("/sitemap/anime.txt", func(ctx *aero.Context) string { + sitemap := sitemap.New() + prefix := "https://" + app.Config.Domain + + for anime := range arn.StreamAnime() { + sitemap.Add(prefix + anime.Link()) + } + + return ctx.Text(sitemap.Text()) + }) + + // Character sitemap + app.Get("/sitemap/character.txt", func(ctx *aero.Context) string { + sitemap := sitemap.New() + prefix := "https://" + app.Config.Domain + + for character := range arn.StreamCharacters() { + sitemap.Add(prefix + character.Link()) + } + + return ctx.Text(sitemap.Text()) + }) + + // User sitemap + app.Get("/sitemap/user.txt", func(ctx *aero.Context) string { + sitemap := sitemap.New() + prefix := "https://" + app.Config.Domain + + for user := range arn.StreamUsers() { + sitemap.Add(prefix + user.Link()) + } + + return ctx.Text(sitemap.Text()) + }) + // For benchmarks app.Get("/hello", func(ctx *aero.Context) string { return ctx.Text("Hello World") diff --git a/middleware/Log.go b/middleware/Log.go index 1a9f9472..40d32c9f 100644 --- a/middleware/Log.go +++ b/middleware/Log.go @@ -68,7 +68,7 @@ func logRequest(ctx *aero.Context, responseTime time.Duration) { // Notify us about long requests. // However ignore requests under /auth/ because those depend on 3rd party servers. - if responseTime >= 200*time.Millisecond && !strings.HasPrefix(ctx.URI(), "/auth/") { + if responseTime >= 300*time.Millisecond && !strings.HasPrefix(ctx.URI(), "/auth/") { err.Error("Long response time", ip, hostName, responseTimeString, ctx.StatusCode, ctx.URI()) } }