mirror of
https://github.com/rancher/steve.git
synced 2025-09-27 23:56:02 +00:00
Add default api-server option
Issue: https://github.com/rancher/steve/pull/14 Refference: https://github.com/rancher/steve/pull/14/commits
This commit is contained in:
@@ -210,10 +210,17 @@ func (s *Server) CustomAPIUIResponseWriter(cssURL, jsURL, version writer.StringG
|
|||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w, ok := wi.(*writer.HTMLResponseWriter)
|
|
||||||
|
gw, ok := wi.(*writer.GzipWriter)
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w, ok := gw.ResponseWriter.(*writer.HTMLResponseWriter)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
w.CSSURL = cssURL
|
w.CSSURL = cssURL
|
||||||
w.JSURL = jsURL
|
w.JSURL = jsURL
|
||||||
w.APIUIVersion = version
|
w.APIUIVersion = version
|
||||||
|
@@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/rancher/steve/pkg/auth"
|
"github.com/rancher/steve/pkg/auth"
|
||||||
"github.com/rancher/steve/pkg/client"
|
"github.com/rancher/steve/pkg/client"
|
||||||
"github.com/rancher/steve/pkg/schema"
|
"github.com/rancher/steve/pkg/schema"
|
||||||
|
"github.com/rancher/steve/pkg/schemaserver/server"
|
||||||
"github.com/rancher/steve/pkg/schemaserver/types"
|
"github.com/rancher/steve/pkg/schemaserver/types"
|
||||||
"github.com/rancher/steve/pkg/server/router"
|
"github.com/rancher/steve/pkg/server/router"
|
||||||
"github.com/rancher/wrangler-api/pkg/generated/controllers/apiextensions.k8s.io"
|
"github.com/rancher/wrangler-api/pkg/generated/controllers/apiextensions.k8s.io"
|
||||||
@@ -32,6 +33,7 @@ type Server struct {
|
|||||||
|
|
||||||
ClientFactory *client.Factory
|
ClientFactory *client.Factory
|
||||||
BaseSchemas *types.APISchemas
|
BaseSchemas *types.APISchemas
|
||||||
|
APIServer *server.Server
|
||||||
AccessSetLookup accesscontrol.AccessSetLookup
|
AccessSetLookup accesscontrol.AccessSetLookup
|
||||||
SchemaTemplates []schema.Template
|
SchemaTemplates []schema.Template
|
||||||
AuthMiddleware auth.Middleware
|
AuthMiddleware auth.Middleware
|
||||||
|
@@ -16,15 +16,19 @@ import (
|
|||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func New(cfg *rest.Config, sf schema.Factory, authMiddleware auth.Middleware, next http.Handler, routerFunc router.RouterFunc) (http.Handler, error) {
|
func New(cfg *rest.Config, sf schema.Factory, authMiddleware auth.Middleware, next http.Handler, routerFunc router.RouterFunc, schemaServer *server.Server) (http.Handler, error) {
|
||||||
var (
|
var (
|
||||||
proxy http.Handler
|
proxy http.Handler
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if schemaServer == nil {
|
||||||
|
schemaServer = server.DefaultAPIServer()
|
||||||
|
}
|
||||||
|
|
||||||
a := &apiServer{
|
a := &apiServer{
|
||||||
sf: sf,
|
sf: sf,
|
||||||
server: server.DefaultAPIServer(),
|
server: schemaServer,
|
||||||
}
|
}
|
||||||
a.server.AccessControl = accesscontrol.NewAccessControl()
|
a.server.AccessControl = accesscontrol.NewAccessControl()
|
||||||
|
|
||||||
|
@@ -89,7 +89,7 @@ func setup(ctx context.Context, server *Server) (http.Handler, *schema.Collectio
|
|||||||
ccache,
|
ccache,
|
||||||
sf)
|
sf)
|
||||||
|
|
||||||
handler, err := handler.New(server.RestConfig, sf, server.AuthMiddleware, server.Next, server.Router)
|
handler, err := handler.New(server.RestConfig, sf, server.AuthMiddleware, server.Next, server.Router, server.APIServer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user