37 Star 411 Fork 76

GVPrancher/rancher

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
server.go 948 Bytes
Copy Edit Raw Blame History
Darren Shepherd authored 2018-01-26 09:06 . Refactor imports
package server
import (
"context"
"net/http"
"net/url"
normanapi "github.com/rancher/norman/api"
"github.com/rancher/norman/parse"
"github.com/rancher/norman/types"
"github.com/rancher/rancher/pkg/api/cluster/api/setup"
"github.com/rancher/rancher/pkg/api/cluster/store"
"github.com/rancher/rancher/pkg/rbac"
"github.com/rancher/types/config"
)
func New(ctx context.Context, cluster *config.ClusterContext) (http.Handler, error) {
if err := setup.Schemas(ctx, cluster, cluster.Schemas); err != nil {
return nil, err
}
server := normanapi.NewAPIServer()
server.AccessControl = rbac.NewAccessControl(cluster.RBAC)
server.URLParser = func(schemas *types.Schemas, url *url.URL) (parse.ParsedURL, error) {
return URLParser(cluster.ClusterName, schemas, url)
}
server.StoreWrapper = store.ProjectSetter(server.StoreWrapper)
if err := server.AddSchemas(cluster.Schemas); err != nil {
return nil, err
}
return server, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.0.0-alpha13

Search

0d507c66 1850385 C8b1a773 1850385