mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-07-04 17:06:49 +00:00
New lint rules
This commit is contained in:
@ -3,17 +3,17 @@ package handler
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
h "npm/internal/api/http"
|
||||
"npm/internal/errors"
|
||||
"npm/internal/logger"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
c "npm/internal/api/context"
|
||||
h "npm/internal/api/http"
|
||||
"npm/internal/entity/auth"
|
||||
"npm/internal/entity/setting"
|
||||
"npm/internal/entity/user"
|
||||
"npm/internal/errors"
|
||||
njwt "npm/internal/jwt"
|
||||
"npm/internal/logger"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
@ -151,7 +151,7 @@ func getCertificateFromRequest(w http.ResponseWriter, r *http.Request) *certific
|
||||
|
||||
// fillObjectFromBody has some reusable code for all endpoints that
|
||||
// have a certificate id in the url. it will write errors to the output.
|
||||
func fillObjectFromBody(w http.ResponseWriter, r *http.Request, validationSchema string, o interface{}) bool {
|
||||
func fillObjectFromBody(w http.ResponseWriter, r *http.Request, validationSchema string, o any) bool {
|
||||
bodyBytes, _ := r.Context().Value(c.BodyCtxKey).([]byte)
|
||||
|
||||
if validationSchema != "" {
|
||||
@ -176,10 +176,10 @@ func fillObjectFromBody(w http.ResponseWriter, r *http.Request, validationSchema
|
||||
return true
|
||||
}
|
||||
|
||||
func configureCertificate(c certificate.Model) {
|
||||
func configureCertificate(cert certificate.Model) {
|
||||
err := jobqueue.AddJob(jobqueue.Job{
|
||||
Name: "RequestCertificate",
|
||||
Action: c.Request,
|
||||
Action: cert.Request,
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("ConfigureCertificateError", err)
|
||||
|
@ -2,6 +2,7 @@ package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
h "npm/internal/api/http"
|
||||
"npm/internal/config"
|
||||
)
|
||||
|
@ -2,6 +2,7 @@ package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"npm/internal/acme"
|
||||
h "npm/internal/api/http"
|
||||
"npm/internal/config"
|
||||
|
@ -56,7 +56,7 @@ func getQueryVarInt(r *http.Request, varName string, required bool, defaultValue
|
||||
}
|
||||
|
||||
func getURLParamInt(r *http.Request, varName string) (uint, error) {
|
||||
var defaultValue uint = 0
|
||||
var defaultValue uint
|
||||
|
||||
required := true
|
||||
paramStr := chi.URLParam(r, varName)
|
||||
|
@ -3,9 +3,10 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"npm/internal/model"
|
||||
"testing"
|
||||
|
||||
"npm/internal/model"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -192,7 +192,7 @@ func GetHostNginxConfig(format string) func(http.ResponseWriter, *http.Request)
|
||||
return
|
||||
}
|
||||
if format == "text" {
|
||||
h.ResultResponseText(w, r, http.StatusOK, content)
|
||||
h.ResultResponseText(w, http.StatusOK, content)
|
||||
return
|
||||
}
|
||||
h.ResultResponseJSON(w, r, http.StatusOK, content)
|
||||
@ -202,11 +202,11 @@ func GetHostNginxConfig(format string) func(http.ResponseWriter, *http.Request)
|
||||
}
|
||||
}
|
||||
|
||||
func configureHost(h host.Model) {
|
||||
func configureHost(hst host.Model) {
|
||||
err := jobqueue.AddJob(jobqueue.Job{
|
||||
Name: "NginxConfigureHost",
|
||||
Action: func() error {
|
||||
return nginx.ConfigureHost(h)
|
||||
return nginx.ConfigureHost(hst)
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
"npm/internal/config"
|
||||
"npm/internal/logger"
|
||||
|
||||
jsref "github.com/jc21/jsref"
|
||||
"github.com/jc21/jsref"
|
||||
"github.com/jc21/jsref/provider"
|
||||
)
|
||||
|
||||
@ -24,7 +24,7 @@ var (
|
||||
// Schema simply reads the swagger schema from disk and returns is raw
|
||||
// Route: GET /schema
|
||||
func Schema() func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
return func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
fmt.Fprint(w, string(getSchema()))
|
||||
@ -42,8 +42,8 @@ func getSchema() []byte {
|
||||
swaggerSchema = []byte(strings.ReplaceAll(string(swaggerSchema), "{{VERSION}}", config.Version))
|
||||
|
||||
// Dereference the JSON Schema:
|
||||
var schema interface{}
|
||||
if err := json.Unmarshal(swaggerSchema, &schema); err != nil {
|
||||
var sch any
|
||||
if err := json.Unmarshal(swaggerSchema, &sch); err != nil {
|
||||
logger.Error("SwaggerUnmarshalError", err)
|
||||
return nil
|
||||
}
|
||||
@ -55,7 +55,7 @@ func getSchema() []byte {
|
||||
logger.Error("SchemaProviderError", err)
|
||||
}
|
||||
|
||||
result, err := resolver.Resolve(schema, "", []jsref.Option{jsref.WithRecursiveResolution(true)}...)
|
||||
result, err := resolver.Resolve(sch, "", []jsref.Option{jsref.WithRecursiveResolution(true)}...)
|
||||
if err != nil {
|
||||
logger.Error("SwaggerResolveError", err)
|
||||
} else {
|
||||
|
@ -95,7 +95,7 @@ func CreateUpstream() func(http.ResponseWriter, *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateHost updates a host
|
||||
// UpdateUpstream updates a stream
|
||||
// Route: PUT /upstreams/{upstreamID}
|
||||
func UpdateUpstream() func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
@ -167,7 +167,7 @@ func DeleteUpstream() func(http.ResponseWriter, *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetHostNginxConfig will return a Host's nginx config from disk
|
||||
// GetUpstreamNginxConfig will return a Host's nginx config from disk
|
||||
// Route: GET /upstreams/{upstreamID}/nginx-config
|
||||
// Route: GET /upstreams/{upstreamID}/nginx-config.txt
|
||||
func GetUpstreamNginxConfig(format string) func(http.ResponseWriter, *http.Request) {
|
||||
@ -191,7 +191,7 @@ func GetUpstreamNginxConfig(format string) func(http.ResponseWriter, *http.Reque
|
||||
return
|
||||
}
|
||||
if format == "text" {
|
||||
h.ResultResponseText(w, r, http.StatusOK, content)
|
||||
h.ResultResponseText(w, http.StatusOK, content)
|
||||
return
|
||||
}
|
||||
h.ResultResponseJSON(w, r, http.StatusOK, content)
|
||||
|
Reference in New Issue
Block a user