func newHealthHandler(ctx *context.RouteContext) http.Handler { router := httprouter.New() router.GET("/health", context.HTTPHandler(getHealth, ctx)) return router }
// NewRouter creates an HTTP router for version 1 of the Clair API. func NewRouter(ctx *context.RouteContext) *httprouter.Router { router := httprouter.New() // Layers router.POST("/layers", context.HTTPHandler(postLayer, ctx)) router.GET("/layers/:layerName", context.HTTPHandler(getLayer, ctx)) router.DELETE("/layers/:layerName", context.HTTPHandler(deleteLayer, ctx)) // Namespaces router.GET("/namespaces", context.HTTPHandler(getNamespaces, ctx)) // Vulnerabilities router.GET("/namespaces/:namespaceName/vulnerabilities", context.HTTPHandler(getVulnerabilities, ctx)) router.POST("/namespaces/:namespaceName/vulnerabilities", context.HTTPHandler(postVulnerability, ctx)) router.GET("/namespaces/:namespaceName/vulnerabilities/:vulnerabilityName", context.HTTPHandler(getVulnerability, ctx)) router.PUT("/namespaces/:namespaceName/vulnerabilities/:vulnerabilityName", context.HTTPHandler(putVulnerability, ctx)) router.DELETE("/namespaces/:namespaceName/vulnerabilities/:vulnerabilityName", context.HTTPHandler(deleteVulnerability, ctx)) // Fixes router.GET("/namespaces/:namespaceName/vulnerabilities/:vulnerabilityName/fixes", context.HTTPHandler(getFixes, ctx)) router.PUT("/namespaces/:namespaceName/vulnerabilities/:vulnerabilityName/fixes/:fixName", context.HTTPHandler(putFix, ctx)) router.DELETE("/namespaces/:namespaceName/vulnerabilities/:vulnerabilityName/fixes/:fixName", context.HTTPHandler(deleteFix, ctx)) // Notifications router.GET("/notifications/:notificationName", context.HTTPHandler(getNotification, ctx)) router.DELETE("/notifications/:notificationName", context.HTTPHandler(deleteNotification, ctx)) // Metrics router.GET("/metrics", context.HTTPHandler(getMetrics, ctx)) return router }