Fix wrong chi version

This commit is contained in:
Jamie Curnow 2023-05-26 19:48:09 +10:00
parent e6ae25d081
commit e61cf52a65
No known key found for this signature in database
GPG Key ID: FFBB624C43388E9E
5 changed files with 17 additions and 12 deletions

View File

@ -11,7 +11,6 @@ require (
github.com/fatih/color v1.15.0
github.com/getsentry/sentry-go v0.21.0
github.com/glebarez/sqlite v1.8.0
github.com/go-chi/chi v4.1.2+incompatible
github.com/go-chi/chi/v5 v5.0.8
github.com/go-chi/cors v1.2.1
github.com/go-chi/jwtauth v4.0.4+incompatible
@ -37,6 +36,7 @@ require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/glebarez/go-sqlite v1.21.1 // indirect
github.com/go-chi/chi v4.1.2+incompatible // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/goccy/go-json v0.9.11 // indirect
github.com/google/uuid v1.3.0 // indirect

View File

@ -8,7 +8,7 @@ import (
"npm/internal/api/context"
"npm/internal/model"
"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/rotisserie/eris"
)
@ -112,7 +112,6 @@ func getURLParamInt(r *http.Request, varName string) (uint, error) {
return defaultValue, nil
}
// func ParseUint(s string, base int, bitSize int) (n uint64, err error)
paramUint, err := strconv.ParseUint(paramStr, 10, 32)
if err != nil {
return 0, eris.Wrapf(err, "%v is not a valid number", varName)

View File

@ -11,7 +11,7 @@ import (
"npm/internal/api/middleware"
"npm/internal/entity/setting"
"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
)
// GetSettings will return a list of Settings

View File

@ -14,7 +14,7 @@ import (
"npm/internal/errors"
"npm/internal/logger"
"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
)
// GetUsers returns all users

View File

@ -85,11 +85,11 @@ func applyRoutes(r chi.Router) chi.Router {
r.With(middleware.EnforceSetup(true)).Route("/", func(r chi.Router) {
// Get yourself, requires a login but no other permissions
r.With(middleware.Enforce("")).
Get("/{userID:(?:me)}", handler.GetUser())
Get("/{userID:me}", handler.GetUser())
// Update yourself, requires a login but no other permissions
r.With(middleware.Enforce(""), middleware.EnforceRequestSchema(schema.UpdateUser())).
Put("/{userID:(?:me)}", handler.UpdateUser())
Put("/{userID:me}", handler.UpdateUser())
r.With(middleware.Enforce(user.CapabilityUsersManage)).Route("/", func(r chi.Router) {
// List
@ -98,19 +98,19 @@ func applyRoutes(r chi.Router) chi.Router {
Get("/", handler.GetUsers())
// Specific Item
r.Get("/{userID:(?:[0-9]+)}", handler.GetUser())
r.Delete("/{userID:(?:[0-9]+|me)}", handler.DeleteUser())
r.Get("/{userID:[0-9]+}", handler.GetUser())
r.Delete("/{userID:([0-9]+|me)}", handler.DeleteUser())
// Update another user
r.With(middleware.EnforceRequestSchema(schema.UpdateUser())).
Put("/{userID:(?:[0-9]+)}", handler.UpdateUser())
Put("/{userID:[0-9]+}", handler.UpdateUser())
})
// Auth - sets passwords
r.With(middleware.Enforce(""), middleware.EnforceRequestSchema(schema.SetAuth())).
Post("/{userID:(?:me)}/auth", handler.SetAuth())
Post("/{userID:me}/auth", handler.SetAuth())
r.With(middleware.Enforce(user.CapabilityUsersManage), middleware.EnforceRequestSchema(schema.SetAuth())).
Post("/{userID:(?:[0-9]+)}/auth", handler.SetAuth())
Post("/{userID:[0-9]+}/auth", handler.SetAuth())
})
})
@ -200,6 +200,12 @@ func applyRoutes(r chi.Router) chi.Router {
r.Route("/{caID:[0-9]+}", func(r chi.Router) {
r.With(middleware.Enforce(user.CapabilityCertificateAuthoritiesView)).
Get("/", handler.GetCertificateAuthority())
r.With(middleware.EnforceRequestSchema(schema.UpdateCertificateAuthority())).
Put("/", handler.UpdateCertificateAuthority())
r.With(middleware.Enforce(user.CapabilityCertificateAuthoritiesManage)).
Delete("/", handler.DeleteCertificateAuthority())
r.With(middleware.Enforce(user.CapabilityCertificateAuthoritiesManage)).Route("/", func(r chi.Router) {
r.Delete("/{caID:[0-9]+}", handler.DeleteCertificateAuthority())
r.With(middleware.EnforceRequestSchema(schema.UpdateCertificateAuthority())).