mirror of
https://github.com/niusmallnan/steve.git
synced 2025-08-31 21:00:22 +00:00
Switch schema ID to gvk and plural name to gvr
This commit is contained in:
@@ -2,10 +2,10 @@ package publicapi
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/rancher/naok/pkg/accesscontrol"
|
||||
"github.com/rancher/naok/pkg/attributes"
|
||||
k8sproxy "github.com/rancher/naok/pkg/proxy"
|
||||
"github.com/rancher/naok/pkg/resources/schema"
|
||||
"github.com/rancher/naok/pkg/server/router"
|
||||
@@ -53,11 +53,12 @@ func (a *apiServer) common(rw http.ResponseWriter, req *http.Request) (*types.AP
|
||||
|
||||
schemas, err := a.sf.Schemas(user)
|
||||
if err != nil {
|
||||
logrus.Errorf("HTTP request failed: %v", err)
|
||||
rw.Write([]byte(err.Error()))
|
||||
rw.WriteHeader(http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
urlBuilder, err := urlbuilder.New(req, a, schemas)
|
||||
urlBuilder, err := urlbuilder.NewPrefixed(req, schemas, "v1")
|
||||
if err != nil {
|
||||
rw.Write([]byte(err.Error()))
|
||||
rw.WriteHeader(http.StatusInternalServerError)
|
||||
@@ -72,14 +73,6 @@ func (a *apiServer) common(rw http.ResponseWriter, req *http.Request) (*types.AP
|
||||
}, true
|
||||
}
|
||||
|
||||
func (a *apiServer) Schema(base string, schema *types.Schema) string {
|
||||
gvr := attributes.GVR(schema)
|
||||
if gvr.Resource == "" {
|
||||
return urlbuilder.ConstructBasicURL(base, "v1", schema.PluralName)
|
||||
}
|
||||
return urlbuilder.ConstructBasicURL(base, "v1", strings.ToLower(schema.ID))
|
||||
}
|
||||
|
||||
type APIFunc func(schema.Factory, *types.APIRequest)
|
||||
|
||||
func (a *apiServer) apiHandler(apiFunc APIFunc) http.Handler {
|
||||
|
Reference in New Issue
Block a user