zotregistry.io/zot@v1.4.4-0.20231124084042-02a8ed785457/pkg/debug/swagger/swagger.go (about)

     1  //go:build debug
     2  // +build debug
     3  
     4  // @contact.name API Support
     5  // @contact.url http://www.swagger.io/support
     6  // @contact.email support@swagger.io
     7  
     8  package debug
     9  
    10  import (
    11  	"github.com/gorilla/mux"
    12  	httpSwagger "github.com/swaggo/http-swagger"
    13  
    14  	"zotregistry.io/zot/pkg/api/config"
    15  	"zotregistry.io/zot/pkg/log" //nolint:goimports
    16  	// as required by swaggo.
    17  	_ "zotregistry.io/zot/swagger"
    18  )
    19  
    20  func SetupSwaggerRoutes(conf *config.Config, router *mux.Router, authFunc mux.MiddlewareFunc,
    21  	log log.Logger,
    22  ) {
    23  	log.Info().Msg("setting up swagger route")
    24  	// swagger "/swagger/v2/index.html"
    25  	swgRouter := router.PathPrefix("/swagger/v2/").Subrouter()
    26  	swgRouter.Use(authFunc)
    27  	swgRouter.Methods("GET").Handler(httpSwagger.WrapHandler)
    28  }