Skip to content

Commit

Permalink
gateway: appease the linter
Browse files Browse the repository at this point in the history
Signed-off-by: Jimmy Zelinskie <jimmy@zelinskie.com>
  • Loading branch information
jzelinskie committed Oct 25, 2021
1 parent 5532b44 commit 699c683
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions cmd/spicedb/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,11 @@ func serveRun(cmd *cobra.Command, args []string) {
}()

// Start the REST gateway to serve HTTP/JSON.
gatewaySrv, err := gateway.NewHttpServer(context.TODO(), gateway.Config{
gatewaySrv, err := gateway.NewHTTPServer(context.TODO(), gateway.Config{
Addr: cobrautil.MustGetStringExpanded(cmd, "http-addr"),
UpstreamAddr: cobrautil.MustGetStringExpanded(cmd, "grpc-addr"),
UpstreamTlsDisabled: cobrautil.MustGetBool(cmd, "grpc-no-tls"),
UpstreamTlsCertPath: cobrautil.MustGetStringExpanded(cmd, "grpc-cert-path"),
UpstreamTLSDisabled: cobrautil.MustGetBool(cmd, "grpc-no-tls"),
UpstreamTLSCertPath: cobrautil.MustGetStringExpanded(cmd, "grpc-cert-path"),
})
if err != nil {
log.Fatal().Err(err).Msg("failed to initialize rest gateway")
Expand Down
18 changes: 9 additions & 9 deletions internal/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,25 @@ type Config struct {
// forwarded.
UpstreamAddr string

// UpstreamTlsDisabled toggles whether or not the upstream connection will be
// UpstreamTLSDisabled toggles whether or not the upstream connection will be
// secure.
UpstreamTlsDisabled bool
UpstreamTLSDisabled bool

// UpstreamTlsCertPath is the filesystem location of the certificate used to
// UpstreamTLSCertPath is the filesystem location of the certificate used to
// secure the upstream connection.
UpstreamTlsCertPath string
UpstreamTLSCertPath string
}

// NewHttpServer initializes a new HTTP server with the provided configuration.
func NewHttpServer(ctx context.Context, cfg Config) (*http.Server, error) {
// NewHTTPServer initializes a new HTTP server with the provided configuration.
func NewHTTPServer(ctx context.Context, cfg Config) (*http.Server, error) {
opts := []grpc.DialOption{
grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor()),
grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor()),
}
if cfg.UpstreamTlsDisabled {
if cfg.UpstreamTLSDisabled {
opts = append(opts, grpc.WithInsecure())
} else {
opts = append(opts, grpcutil.WithCustomCerts(cfg.UpstreamTlsCertPath, grpcutil.SkipVerifyCA))
opts = append(opts, grpcutil.WithCustomCerts(cfg.UpstreamTLSCertPath, grpcutil.SkipVerifyCA))
}

gwMux := runtime.NewServeMux(runtime.WithMetadata(OtelAnnotator))
Expand All @@ -69,7 +69,7 @@ func NewHttpServer(ctx context.Context, cfg Config) (*http.Server, error) {

mux := http.NewServeMux()
mux.Handle("/openapi.json", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, proto.OpenAPISchema)
_, _ = io.WriteString(w, proto.OpenAPISchema)
}))
mux.Handle("/", gwMux)

Expand Down

0 comments on commit 699c683

Please sign in to comment.