Skip to content

Commit

Permalink
feat: update chi version (#1581)
Browse files Browse the repository at this point in the history
## What kind of change does this PR introduce?
* Upgrades [chi](https://github.com/go-chi/chi) from v4 to v5
  • Loading branch information
kangmingtay committed May 17, 2024
1 parent c22fc15 commit c64ae3d
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cmd/serve_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func serve(ctx context.Context) {
}
defer db.Close()

api := api.NewAPIWithVersion(ctx, config, db, utilities.Version)
api := api.NewAPIWithVersion(config, db, utilities.Version)

addr := net.JoinHostPort(config.API.Host, config.API.Port)
logrus.Infof("GoTrue API started on: %s", addr)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc
github.com/coreos/go-oidc/v3 v3.6.0
github.com/didip/tollbooth/v5 v5.1.1
github.com/go-chi/chi v4.0.2+incompatible
github.com/gobuffalo/validate/v3 v3.3.3 // indirect
github.com/gobwas/glob v0.2.3
github.com/gofrs/uuid v4.3.1+incompatible
Expand Down Expand Up @@ -68,6 +67,7 @@ require (
github.com/crewjam/saml v0.4.14
github.com/deepmap/oapi-codegen v1.12.4
github.com/fatih/structs v1.1.0
github.com/go-chi/chi/v5 v5.0.12
github.com/gobuffalo/pop/v6 v6.1.1
github.com/jackc/pgx/v4 v4.18.2
github.com/standard-webhooks/standard-webhooks/libraries v0.0.0-20240303152453-e0e82adf1721
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-chi/chi v4.0.2+incompatible h1:maB6vn6FqCxrpz4FqWdh4+lwpyZIQS7YEAUcHlgXVRs=
github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s=
github.com/go-chi/chi/v5 v5.0.12/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 Expand Up @@ -490,8 +490,6 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/supabase/hibp v0.0.0-20231124125943-d225752ae869 h1:VDuRtwen5Z7QQ5ctuHUse4wAv/JozkKZkdic5vUV4Lg=
github.com/supabase/hibp v0.0.0-20231124125943-d225752ae869/go.mod h1:eHX5nlSMSnyPjUrbYzeqrA8snCe2SKyfizKjU3dkfOw=
github.com/supabase/mailme v0.1.0 h1:1InJqMMPTFqZfRZ/gnsCwOc+oUWCFuxSXhlCCG6zYUo=
github.com/supabase/mailme v0.1.0/go.mod h1:kWsnmPfUBZTavlXYkfJrE9unzmmRAIi/kqsxXfEWEY8=
github.com/supabase/mailme v0.2.0 h1:39LHZ4+YOeqoN4MiuncPBC3JarExAa0flmokM24qHNU=
github.com/supabase/mailme v0.2.0/go.mod h1:kWsnmPfUBZTavlXYkfJrE9unzmmRAIi/kqsxXfEWEY8=
github.com/twmb/murmur3 v1.1.6 h1:mqrRot1BRxm+Yct+vavLMou2/iJt0tNVTTC0QoIjaZg=
Expand Down
2 changes: 1 addition & 1 deletion internal/api/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/fatih/structs"
"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/gofrs/uuid"
"github.com/sethvargo/go-password/password"
"github.com/supabase/auth/internal/api/provider"
Expand Down
8 changes: 3 additions & 5 deletions internal/api/api.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package api

import (
"context"
"net/http"
"regexp"
"time"

"github.com/didip/tollbooth/v5"
"github.com/didip/tollbooth/v5/limiter"
"github.com/go-chi/chi"
"github.com/rs/cors"
"github.com/sebest/xff"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -51,7 +49,7 @@ func (a *API) Now() time.Time {

// NewAPI instantiates a new REST API
func NewAPI(globalConfig *conf.GlobalConfiguration, db *storage.Connection) *API {
return NewAPIWithVersion(context.Background(), globalConfig, db, defaultVersion)
return NewAPIWithVersion(globalConfig, db, defaultVersion)
}

func (a *API) deprecationNotices() {
Expand All @@ -69,7 +67,7 @@ func (a *API) deprecationNotices() {
}

// NewAPIWithVersion creates a new REST API using the specified version
func NewAPIWithVersion(ctx context.Context, globalConfig *conf.GlobalConfiguration, db *storage.Connection, version string) *API {
func NewAPIWithVersion(globalConfig *conf.GlobalConfiguration, db *storage.Connection, version string) *API {
api := &API{config: globalConfig, db: db, version: version}

if api.config.Password.HIBP.Enabled {
Expand Down Expand Up @@ -293,7 +291,7 @@ func NewAPIWithVersion(ctx context.Context, globalConfig *conf.GlobalConfigurati
AllowCredentials: true,
})

api.handler = corsHandler.Handler(chi.ServerBaseContext(ctx, r))
api.handler = corsHandler.Handler(r)
return api
}

Expand Down
3 changes: 1 addition & 2 deletions internal/api/api_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package api

import (
"context"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -46,7 +45,7 @@ func setupAPIForTestWithCallback(cb func(*conf.GlobalConfiguration, *storage.Con
cb(nil, conn)
}

return NewAPIWithVersion(context.Background(), config, conn, apiTestVersion), config, nil
return NewAPIWithVersion(config, conn, apiTestVersion), config, nil
}

func TestEmailEnabledByDefault(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/api/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"

"github.com/fatih/structs"
"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/gofrs/uuid"
"github.com/pkg/errors"
"github.com/supabase/auth/internal/api/provider"
Expand Down
2 changes: 1 addition & 1 deletion internal/api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"net/http"

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

func newRouter() *router {
Expand Down
2 changes: 1 addition & 1 deletion internal/api/ssoadmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/crewjam/saml"
"github.com/crewjam/saml/samlsp"
"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/gofrs/uuid"
"github.com/supabase/auth/internal/models"
"github.com/supabase/auth/internal/observability"
Expand Down
4 changes: 2 additions & 2 deletions internal/observability/request-logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"
"time"

chimiddleware "github.com/go-chi/chi/middleware"
chimiddleware "github.com/go-chi/chi/v5/middleware"
"github.com/gofrs/uuid"
"github.com/sirupsen/logrus"
"github.com/supabase/auth/internal/conf"
Expand Down Expand Up @@ -68,7 +68,7 @@ type logEntry struct {
Entry *logrus.Entry
}

func (e *logEntry) Write(status, bytes int, elapsed time.Duration) {
func (e *logEntry) Write(status, bytes int, header http.Header, elapsed time.Duration, extra interface{}) {
entry := e.Entry.WithFields(logrus.Fields{
"status": status,
"duration": elapsed.Nanoseconds(),
Expand Down
2 changes: 1 addition & 1 deletion internal/observability/request-tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"net/http"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/sirupsen/logrus"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.opentelemetry.io/otel/attribute"
Expand Down

0 comments on commit c64ae3d

Please sign in to comment.