api/v2: Disable serving swagger spec and redoc UI

By default go-swagger serves the swagger spec and the redoc UI. This
patch disables both.

Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
This commit is contained in:
Max Leonard Inden 2019-01-16 16:18:05 +01:00
parent 4b22f6128e
commit c4d1b5b93f
No known key found for this signature in database
GPG Key ID: 5403C5464810BC26
1 changed files with 6 additions and 0 deletions

View File

@ -91,6 +91,12 @@ func NewAPI(alerts provider.Alerts, sf getAlertStatusFn, silences *silence.Silen
// create new service API
openAPI := operations.NewAlertmanagerAPI(swaggerSpec)
// Skip swagger spec and redoc middleware, only serving the API itself via
// RoutesHandler. See: https://github.com/go-swagger/go-swagger/issues/1779
openAPI.Middleware = func(b middleware.Builder) http.Handler {
return middleware.Spec("", nil, openAPI.Context().RoutesHandler(b))
}
openAPI.AlertGetAlertsHandler = alert_ops.GetAlertsHandlerFunc(api.getAlertsHandler)
openAPI.AlertPostAlertsHandler = alert_ops.PostAlertsHandlerFunc(api.postAlertsHandler)
openAPI.GeneralGetStatusHandler = general_ops.GetStatusHandlerFunc(api.getStatusHandler)