mirror of
https://github.com/gabehf/sonarr-anime-importer.git
synced 2026-03-19 20:06:25 -07:00
feat: Anilist support
This commit is contained in:
parent
ec6c1cc0e0
commit
cdd7b67003
8 changed files with 541 additions and 143 deletions
26
middleware.go
Normal file
26
middleware.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func newRebuildStaleIdMapMiddleware(idMap *ConcurrentMap) func(http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if time.Since(lastBuiltAnimeIdList) > 24*time.Hour {
|
||||
log.Println("Anime ID association table expired, building new table...")
|
||||
buildIdMap(idMap)
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func loggerMiddleware(next http.Handler) http.HandlerFunc {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("%s %s?%s", r.Method, r.URL.Path, r.URL.RawQuery)
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue