mirror of
https://github.com/niusmallnan/steve.git
synced 2026-01-29 21:38:35 +00:00
Make / and /v1 work
This commit is contained in:
@@ -36,6 +36,7 @@ func NewHandler(cfg *rest.Config, sf schema.Factory) (http.Handler, error) {
|
||||
K8sResource: a.apiHandler(k8sAPI),
|
||||
GenericResource: a.apiHandler(nil),
|
||||
K8sProxy: proxy,
|
||||
APIRoot: a.apiHandler(apiRoot),
|
||||
}), nil
|
||||
}
|
||||
|
||||
|
||||
@@ -36,3 +36,7 @@ func k8sAPI(sf schema.Factory, apiOp *types.APIRequest) {
|
||||
apiOp.Namespaces = []string{namespace}
|
||||
}
|
||||
}
|
||||
|
||||
func apiRoot(sf schema.Factory, apiOp *types.APIRequest) {
|
||||
apiOp.Type = "apiRoot"
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
type Handlers struct {
|
||||
K8sResource http.Handler
|
||||
GenericResource http.Handler
|
||||
APIRoot http.Handler
|
||||
K8sProxy http.Handler
|
||||
}
|
||||
|
||||
@@ -18,6 +19,9 @@ func Routes(h Handlers) http.Handler {
|
||||
m.StrictSlash(true)
|
||||
m.NotFoundHandler = h.K8sProxy
|
||||
|
||||
m.Path("/").Handler(h.APIRoot)
|
||||
m.Path("/{name:v1}").Handler(h.APIRoot)
|
||||
|
||||
m.Path("/v1/{type:schemas}/{name:.*}").Handler(h.GenericResource)
|
||||
m.Path("/v1/{group}.{version}.{resource}").Handler(h.K8sResource)
|
||||
m.Path("/v1/{group}.{version}.{resource}/{nameorns}").Handler(h.K8sResource)
|
||||
|
||||
Reference in New Issue
Block a user