Skip to content

Commit

Permalink
revert to original router creation source for registry index server.
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Valdron <mvaldron@redhat.com>
  • Loading branch information
michael-valdron committed Aug 16, 2022
1 parent 0d02e2e commit 7e5e704
Showing 1 changed file with 21 additions and 29 deletions.
50 changes: 21 additions & 29 deletions index/server/pkg/server/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,33 +49,6 @@ var getIndexLatency = prometheus.NewHistogramVec(
[]string{"status"},
)

// CreateIndexServer creates index server engine with REST API endpoints
func CreateIndexServer() *gin.Engine {
// Start the server and serve requests and index.json
router := gin.Default()

// Registry REST APIs
router.GET("/", serveRootEndpoint)
router.GET("/index", serveDevfileIndexV1)
router.GET("/index/:type", serveDevfileIndexV1WithType)
router.GET("/health", serveHealthCheck)
router.GET("/devfiles/:name", serveDevfile)
router.GET("/devfiles/:name/:version", serveDevfileWithVersion)
router.GET("/devfiles/:name/starter-projects/:starterProjectName", serveDevfileStarterProject)
router.GET("/devfiles/:name/:version/starter-projects/:starterProjectName", serveDevfileStarterProjectWithVersion)

// Registry REST APIs for index v2
router.GET("/v2index", serveDevfileIndexV2)
router.GET("/v2index/:type", serveDevfileIndexV2WithType)

// Set up a simple proxy for /v2 endpoints
// Only allow HEAD and GET requests
router.HEAD("/v2/*proxyPath", ociServerProxy)
router.GET("/v2/*proxyPath", ociServerProxy)

return router
}

func ServeRegistry() {
// Enable metrics
// Run on a separate port and router from the index server so that it's not exposed publicly
Expand Down Expand Up @@ -153,8 +126,27 @@ func ServeRegistry() {
log.Println("Telemetry is not enabled")
}

// Create index server with REST API endpoints
router := CreateIndexServer()
// Start the server and serve requests and index.json
router := gin.Default()

// Registry REST APIs
router.GET("/", serveRootEndpoint)
router.GET("/index", serveDevfileIndexV1)
router.GET("/index/:type", serveDevfileIndexV1WithType)
router.GET("/health", serveHealthCheck)
router.GET("/devfiles/:name", serveDevfile)
router.GET("/devfiles/:name/:version", serveDevfileWithVersion)
router.GET("/devfiles/:name/starter-projects/:starterProjectName", serveDevfileStarterProject)
router.GET("/devfiles/:name/:version/starter-projects/:starterProjectName", serveDevfileStarterProjectWithVersion)

// Registry REST APIs for index v2
router.GET("/v2index", serveDevfileIndexV2)
router.GET("/v2index/:type", serveDevfileIndexV2WithType)

// Set up a simple proxy for /v2 endpoints
// Only allow HEAD and GET requests
router.HEAD("/v2/*proxyPath", ociServerProxy)
router.GET("/v2/*proxyPath", ociServerProxy)

// Set up routes for the registry viewer
router.GET("/viewer", serveUI)
Expand Down

0 comments on commit 7e5e704

Please sign in to comment.