-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
41 lines (32 loc) · 1.19 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"fmt"
controlplanedocs "github.com/open-privacy/opv/cmd/controlplane/docs" // docs is generated by Swag CLI, you have to import it.
echoSwagger "github.com/swaggo/echo-swagger"
"github.com/open-privacy/opv/pkg/config"
"github.com/open-privacy/opv/pkg/controlplane"
"github.com/tj/go-gracefully"
)
// @title Open Privacy Vault Control Plane API
// @version 1.0
// @description Open Privacy Vault Control Plane API.
// @host localhost
// @basePath /api/v1
// @tag.name Grant
// @tag.description A grant is the unit of grant to access certain resource in OPV
func main() {
cp := controlplane.MustNewControlPlane()
cp.Start()
defer cp.Stop()
setupSwaggerUI(cp)
gracefully.Timeout = config.ENV.GracefullyShutdownTimeout
gracefully.Shutdown()
}
func setupSwaggerUI(cp *controlplane.ControlPlane) {
controlplanedocs.SwaggerInfo.Host = fmt.Sprintf("%s:%d", config.ENV.Host, config.ENV.ControlPlanePort)
controlplanedocs.SwaggerInfo.Schemes = config.ENV.ControlPlaneSwaggerSchemesOverride
if config.ENV.ControlPlaneSwaggerHostOverride != "" {
controlplanedocs.SwaggerInfo.Host = config.ENV.ControlPlaneSwaggerHostOverride
}
cp.Echo.GET("/swagger/*", echoSwagger.WrapHandler)
}