gateway

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupGateway

func SetupGateway(grpcPort, httpPort, tlsCertFile, commonName string, allowedIPs, deniedIPs []string,
	blockByDefault, trustProxy, startTLS bool) (*http.Server, *runtime.ServeMux, string, []grpc.DialOption, error)

SetupGateway configures and returns an HTTP server that acts as a gateway to a gRPC service. The gateway is forced to connect to localhost regardless of the provided grpcPort hostname.

Important note about localhost and certificates: The gateway always establishes its connection to the gRPC server through localhost (e.g., localhost:50051). Therefore, if the TLS certificate does not include "localhost" in its subject/SAN fields, the connection will fail with a certificate validation error. The commonName parameter allows you to override the hostname verification in such cases.

For example:

  • If your certificate is issued for "api.example.com" without "localhost" in SAN: Set commonName="api.example.com" to match the certificate's subject.
  • If your certificate includes "localhost" in SAN: Set commonName="localhost" (or it can be left empty as "localhost" is the default).

func StartGateway

func StartGateway(srv *http.Server, tlsCertFile, tlsKeyFile string, startTLS bool)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL