mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 12:58:02 +08:00
Added graphql api feature for image vulnerability scanning
This commit is contained in:
@@ -21,8 +21,10 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
gqlHandler "github.com/99designs/gqlgen/graphql/handler"
|
||||
_ "github.com/anuvu/zot/docs" // as required by swaggo
|
||||
"github.com/anuvu/zot/errors"
|
||||
"github.com/anuvu/zot/pkg/extensions/search"
|
||||
"github.com/anuvu/zot/pkg/log"
|
||||
"github.com/gorilla/mux"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
@@ -50,6 +52,11 @@ func NewRouteHandler(c *Controller) *RouteHandler {
|
||||
return rh
|
||||
}
|
||||
|
||||
func (rh *RouteHandler) searchHandler() *gqlHandler.Server {
|
||||
resConfig := search.GetResolverConfig(rh.c.Config.Storage.RootDirectory, rh.c.Log, rh.c.ImageStore)
|
||||
return gqlHandler.NewDefaultServer(search.NewExecutableSchema(resConfig))
|
||||
}
|
||||
|
||||
// blobRLockWrapper calls the real handler with read-lock held.
|
||||
func (rh *RouteHandler) blobRLockWrapper(f func(w http.ResponseWriter,
|
||||
r *http.Request)) func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -107,6 +114,10 @@ func (rh *RouteHandler) SetupRoutes() {
|
||||
}
|
||||
// swagger docs "/swagger/v2/index.html"
|
||||
rh.c.Router.PathPrefix("/swagger/v2/").Methods("GET").Handler(httpSwagger.WrapHandler)
|
||||
// Zot Search Extension Router
|
||||
if rh.c.Config != nil && rh.c.Config.Extensions != nil {
|
||||
rh.c.Router.PathPrefix("/query").Methods("GET", "POST").Handler(rh.searchHandler())
|
||||
}
|
||||
}
|
||||
|
||||
// Method handlers
|
||||
|
||||
Reference in New Issue
Block a user