Skip to content

Commit

Permalink
feat: skip traffic control on streaming requests
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyXiang committed Dec 17, 2023
1 parent 6dad129 commit bbf8846
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions handler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ func NewRouter() http.Handler {
if !plexClient.NoRequestLogs {
r.Use(middleware.Logger)
}
r.Use(wrapMiddleware, middleware.Recoverer, trafficMiddleware)
r.Use(wrapMiddleware, middleware.Recoverer)

// bypass cache
r.PathPrefix("/:/").Handler(plexClient)
r.PathPrefix("/library/parts/").Handler(plexClient)
streamingRouter := r.NewRoute().Subrouter()
streamingRouter.PathPrefix("/library/parts/").Handler(plexClient)
streamingRouter.PathPrefix("/video/:/transcode/").Handler(plexClient)

staticRouter := r.Methods(http.MethodGet).Subrouter()
getRouter := r.Methods(http.MethodGet).Subrouter()
getRouter.Use(trafficMiddleware)
getRouter.PathPrefix("/:/").Handler(plexClient)

staticRouter := getRouter.NewRoute().Subrouter()
staticRouter.Use(staticMiddleware)
staticRouter.Path("/library/media/{key}/chapterImages/{id}").Handler(plexClient)
staticRouter.Path("/library/metadata/{key}/art/{id}").Handler(plexClient)
Expand All @@ -52,7 +56,7 @@ func NewRouter() http.Handler {
staticRouter.PathPrefix("/web/js/").Handler(plexClient)
staticRouter.PathPrefix("/web/static/").Handler(plexClient)

dynamicRouter := r.Methods(http.MethodGet).Subrouter()
dynamicRouter := getRouter.NewRoute().Subrouter()
dynamicRouter.Use(dynamicMiddleware)
dynamicRouter.PathPrefix("/").Handler(plexClient)

Expand Down

0 comments on commit bbf8846

Please # to comment.