Skip to content

Commit e61cf52

Browse files
committed
Fix wrong chi version
1 parent e6ae25d commit e61cf52

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

backend/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ require (
1111
github.com/fatih/color v1.15.0
1212
github.com/getsentry/sentry-go v0.21.0
1313
github.com/glebarez/sqlite v1.8.0
14-
github.com/go-chi/chi v4.1.2+incompatible
1514
github.com/go-chi/chi/v5 v5.0.8
1615
github.com/go-chi/cors v1.2.1
1716
github.com/go-chi/jwtauth v4.0.4+incompatible
@@ -37,6 +36,7 @@ require (
3736
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
3837
github.com/dustin/go-humanize v1.0.1 // indirect
3938
github.com/glebarez/go-sqlite v1.21.1 // indirect
39+
github.com/go-chi/chi v4.1.2+incompatible // indirect
4040
github.com/go-sql-driver/mysql v1.7.1 // indirect
4141
github.com/goccy/go-json v0.9.11 // indirect
4242
github.com/google/uuid v1.3.0 // indirect

backend/internal/api/handler/helpers.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"npm/internal/api/context"
99
"npm/internal/model"
1010

11-
"github.com/go-chi/chi"
11+
"github.com/go-chi/chi/v5"
1212
"github.com/rotisserie/eris"
1313
)
1414

@@ -112,7 +112,6 @@ func getURLParamInt(r *http.Request, varName string) (uint, error) {
112112
return defaultValue, nil
113113
}
114114

115-
// func ParseUint(s string, base int, bitSize int) (n uint64, err error)
116115
paramUint, err := strconv.ParseUint(paramStr, 10, 32)
117116
if err != nil {
118117
return 0, eris.Wrapf(err, "%v is not a valid number", varName)

backend/internal/api/handler/settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"npm/internal/api/middleware"
1212
"npm/internal/entity/setting"
1313

14-
"github.com/go-chi/chi"
14+
"github.com/go-chi/chi/v5"
1515
)
1616

1717
// GetSettings will return a list of Settings

backend/internal/api/handler/users.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"npm/internal/errors"
1515
"npm/internal/logger"
1616

17-
"github.com/go-chi/chi"
17+
"github.com/go-chi/chi/v5"
1818
)
1919

2020
// GetUsers returns all users

backend/internal/api/router.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ func applyRoutes(r chi.Router) chi.Router {
8585
r.With(middleware.EnforceSetup(true)).Route("/", func(r chi.Router) {
8686
// Get yourself, requires a login but no other permissions
8787
r.With(middleware.Enforce("")).
88-
Get("/{userID:(?:me)}", handler.GetUser())
88+
Get("/{userID:me}", handler.GetUser())
8989

9090
// Update yourself, requires a login but no other permissions
9191
r.With(middleware.Enforce(""), middleware.EnforceRequestSchema(schema.UpdateUser())).
92-
Put("/{userID:(?:me)}", handler.UpdateUser())
92+
Put("/{userID:me}", handler.UpdateUser())
9393

9494
r.With(middleware.Enforce(user.CapabilityUsersManage)).Route("/", func(r chi.Router) {
9595
// List
@@ -98,19 +98,19 @@ func applyRoutes(r chi.Router) chi.Router {
9898
Get("/", handler.GetUsers())
9999

100100
// Specific Item
101-
r.Get("/{userID:(?:[0-9]+)}", handler.GetUser())
102-
r.Delete("/{userID:(?:[0-9]+|me)}", handler.DeleteUser())
101+
r.Get("/{userID:[0-9]+}", handler.GetUser())
102+
r.Delete("/{userID:([0-9]+|me)}", handler.DeleteUser())
103103

104104
// Update another user
105105
r.With(middleware.EnforceRequestSchema(schema.UpdateUser())).
106-
Put("/{userID:(?:[0-9]+)}", handler.UpdateUser())
106+
Put("/{userID:[0-9]+}", handler.UpdateUser())
107107
})
108108

109109
// Auth - sets passwords
110110
r.With(middleware.Enforce(""), middleware.EnforceRequestSchema(schema.SetAuth())).
111-
Post("/{userID:(?:me)}/auth", handler.SetAuth())
111+
Post("/{userID:me}/auth", handler.SetAuth())
112112
r.With(middleware.Enforce(user.CapabilityUsersManage), middleware.EnforceRequestSchema(schema.SetAuth())).
113-
Post("/{userID:(?:[0-9]+)}/auth", handler.SetAuth())
113+
Post("/{userID:[0-9]+}/auth", handler.SetAuth())
114114
})
115115
})
116116

@@ -200,6 +200,12 @@ func applyRoutes(r chi.Router) chi.Router {
200200
r.Route("/{caID:[0-9]+}", func(r chi.Router) {
201201
r.With(middleware.Enforce(user.CapabilityCertificateAuthoritiesView)).
202202
Get("/", handler.GetCertificateAuthority())
203+
204+
r.With(middleware.EnforceRequestSchema(schema.UpdateCertificateAuthority())).
205+
Put("/", handler.UpdateCertificateAuthority())
206+
r.With(middleware.Enforce(user.CapabilityCertificateAuthoritiesManage)).
207+
Delete("/", handler.DeleteCertificateAuthority())
208+
203209
r.With(middleware.Enforce(user.CapabilityCertificateAuthoritiesManage)).Route("/", func(r chi.Router) {
204210
r.Delete("/{caID:[0-9]+}", handler.DeleteCertificateAuthority())
205211
r.With(middleware.EnforceRequestSchema(schema.UpdateCertificateAuthority())).

0 commit comments

Comments
 (0)