mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-25 17:12:50 +00:00
feat: add resources tags api (#2604)
Signed-off-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
parent
72680b80be
commit
878b69a9bd
|
|
@ -12,11 +12,14 @@ const (
|
|||
// This tag is used to identify and categorize KubeKey-specific resources
|
||||
// in the system, making it easier to filter and manage them
|
||||
KubeKeyTag = "kubekey"
|
||||
|
||||
// OpenAPITag is the tag used for OpenAPI documentation
|
||||
// This tag helps organize and identify OpenAPI/Swagger documentation
|
||||
// related to the KubeKey API endpoints
|
||||
OpenAPITag = "api"
|
||||
// ResourceTag is the tag used for resource-related endpoints
|
||||
// This tag helps organize and identify API endpoints that deal with
|
||||
// resource management and operations
|
||||
ResourceTag = "resources"
|
||||
|
||||
// StatusOK represents a successful operation status
|
||||
// Used to indicate that an API operation completed successfully
|
||||
|
|
|
|||
|
|
@ -3,19 +3,22 @@ package web
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
|
||||
_const "github.com/kubesphere/kubekey/v4/pkg/const"
|
||||
)
|
||||
|
||||
// NewSchemaService creates a new WebService that serves schema files from the specified root path.
|
||||
// It sets up a route that handles GET requests to /schema/{subpath} and serves files from the rootPath directory.
|
||||
// The {subpath:*} parameter allows for matching any path under /schema/.
|
||||
// It sets up a route that handles GET requests to /resources/schema/{subpath} and serves files from the rootPath directory.
|
||||
// The {subpath:*} parameter allows for matching any path under /resources/schema/.
|
||||
func NewSchemaService(rootPath string) *restful.WebService {
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/schema")
|
||||
ws.Path("resources/schema")
|
||||
|
||||
ws.Route(ws.GET("/{subpath:*}").To(func(req *restful.Request, resp *restful.Response) {
|
||||
http.StripPrefix("/schema/", http.FileServer(http.Dir(rootPath))).ServeHTTP(resp.ResponseWriter, req.Request)
|
||||
}))
|
||||
http.StripPrefix("resources/schema/", http.FileServer(http.Dir(rootPath))).ServeHTTP(resp.ResponseWriter, req.Request)
|
||||
}).Metadata(restfulspec.KeyOpenAPITags, []string{_const.ResourceTag}))
|
||||
|
||||
return ws
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue