Skip to content

Commit

Permalink
upgrade go chi v5.
Browse files Browse the repository at this point in the history
  • Loading branch information
m1k1o committed Nov 25, 2023
1 parent ee220f0 commit 0f166b1
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 46 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.17

require (
github.com/fsnotify/fsnotify v1.5.1
github.com/go-chi/chi v1.5.4
github.com/go-chi/chi/v5 v5.0.10
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/rs/zerolog v1.25.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-chi/chi v1.5.4 h1:QHdzF2szwjqVV4wmByUnTcsbIg7UGaQ0tPF2t5GcAIs=
github.com/go-chi/chi v1.5.4/go.mod h1:uaf8YgoFazUOkPBG7fxPftUylNumIev9awIWOENIuEg=
github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk=
github.com/go-chi/chi/v5 v5.0.10/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
Expand Down
2 changes: 1 addition & 1 deletion internal/api/hls.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
"os/exec"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/rs/zerolog/log"

"github.com/m1k1o/go-transcode/hls"
Expand Down
2 changes: 1 addition & 1 deletion internal/api/hlsproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"net/http"
"strings"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"

"github.com/m1k1o/go-transcode/hlsproxy"
)
Expand Down
5 changes: 3 additions & 2 deletions internal/api/hlsvod.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import (
"path/filepath"
"strings"

"github.com/go-chi/chi"
"github.com/m1k1o/go-transcode/hlsvod"
"github.com/go-chi/chi/v5"
"github.com/rs/zerolog/log"

"github.com/m1k1o/go-transcode/hlsvod"
)

var hlsVodManagers map[string]hlsvod.Manager = make(map[string]hlsvod.Manager)
Expand Down
2 changes: 1 addition & 1 deletion internal/api/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"
"os/exec"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/rs/zerolog/log"

"github.com/m1k1o/go-transcode/internal/utils"
Expand Down
2 changes: 1 addition & 1 deletion internal/api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"path"
"regexp"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/rs/zerolog/log"

"github.com/m1k1o/go-transcode/internal/config"
Expand Down
31 changes: 0 additions & 31 deletions internal/http/debug.go

This file was deleted.

8 changes: 6 additions & 2 deletions internal/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"
"time"

"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"

Expand Down Expand Up @@ -87,6 +87,10 @@ func (s *HttpManagerCtx) Shutdown() error {
return s.http.Shutdown(ctx)
}

func (s *HttpManagerCtx) WithProfiler() {
s.router.Mount("/debug", middleware.Profiler())
}

func (s *HttpManagerCtx) Mount(fn func(r *chi.Mux)) {
fn(s.router)
}
2 changes: 1 addition & 1 deletion internal/http/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"
"time"

"github.com/go-chi/chi/middleware"
"github.com/go-chi/chi/v5/middleware"
"github.com/rs/zerolog"
)

Expand Down
5 changes: 2 additions & 3 deletions internal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ func (main *Main) Start() {
main.httpManager.Start()

if main.RootConfig.PProf {
pathPrefix := "/debug/pprof/"
main.httpManager.WithDebugPProf(pathPrefix)
main.logger.Info().Msgf("mounted debug pprof endpoint at %s", pathPrefix)
main.httpManager.WithProfiler()
main.logger.Info().Msgf("mounted debug pprof endpoint")
}

main.logger.Info().Msgf("serving streams from basedir %s: %s", config.BaseDir, config.Streams)
Expand Down

0 comments on commit 0f166b1

Please sign in to comment.