server

package
v0.0.0-...-bfdf4f8 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: BSD-2-Clause Imports: 39 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SampleCustomHeaderMiddleware

func SampleCustomHeaderMiddleware(next http.Handler) http.Handler

Types

type FabricBrokerConfig

type FabricBrokerConfig struct {
	FabricEndpoint string              `json:"fabric_endpoint"` // URI to WebSocket endpoint
	EndpointConfig *bus.EndpointConfig `json:"endpoint_config"` // STOMP configuration
}

FabricBrokerConfig defines the endpoint for WebSocket as well as detailed endpoint configuration

type NoDirFileSystem

type NoDirFileSystem struct {
	// contains filtered or unexported fields
}

func (NoDirFileSystem) Open

func (nd NoDirFileSystem) Open(name string) (http.File, error)

type PlatformServer

type PlatformServer interface {
	StartServer(syschan chan os.Signal)                                 // start server
	StopServer()                                                        // stop server
	RegisterService(svc service.FabricService, svcChannel string) error // register a new service at given channel
	SetHttpChannelBridge(bridgeConfig *service.RESTBridgeConfig)        // set up a REST bridge for a service
	SetStaticRoute(prefix, fullpath string)                             // set up a static content route
	CustomizeTLSConfig(tls *tls.Config) error                           // used to replace default tls.Config for HTTP server with a custom config
	GetRestBridgeSubRoute(uri, method string) (*mux.Route, error)       // get *mux.Route that maps to the provided uri and method
	GetMiddlewareManager() middleware.MiddlewareManager                 // get middleware manager
}

PlatformServer exposes public API methods that control the behavior of the Plank instance.

func NewPlatformServer

func NewPlatformServer(config *PlatformServerConfig) PlatformServer

NewPlatformServer configures and returns a new platformServer instance

func NewPlatformServerFromConfig

func NewPlatformServerFromConfig(configPath string) (PlatformServer, error)

NewPlatformServerFromConfig returns a new instance of PlatformServer based on the config JSON file provided as configPath

type PlatformServerConfig

type PlatformServerConfig struct {
	RootDir                    string              `json:"root_dir"`                       // root directory the server should base itself on
	StaticDir                  []string            `json:"static_dir"`                     // static content folders that HTTP server should serve
	SpaConfig                  *SpaConfig          `json:"spa_config"`                     // single page application configuration
	Host                       string              `json:"host"`                           // hostname for the server
	Port                       int                 `json:"port"`                           // port for the server
	LogConfig                  *utils.LogConfig    `json:"log_config"`                     // log configuration (plank, http access and error logs)
	FabricConfig               *FabricBrokerConfig `json:"fabric_config"`                  // fabric (websocket) configuration
	TLSCertConfig              *TLSCertConfig      `json:"tls_config"`                     // TLS certificate configuration
	EnablePrometheus           bool                `json:"enable_prometheus"`              // whether to enable Prometheus for runtime metrics
	Debug                      bool                `json:"debug"`                          // enable debug logging
	NoBanner                   bool                `json:"no_banner"`                      // start server without displaying the banner
	ShutdownTimeoutInMinutes   time.Duration       `json:"shutdown_timeout_in_minutes"`    // graceful server shutdown timeout in minutes
	RestBridgeTimeoutInMinutes time.Duration       `json:"rest_bridge_timeout_in_minutes"` // rest bridge timeout in minutes
}

PlatformServerConfig holds all the core configuration needed for the functionality of Plank

func CreateServerConfig

func CreateServerConfig() (*PlatformServerConfig, error)

CreateServerConfig creates a new instance of PlatformServerConfig and returns the pointer to it.

func CreateServerConfigForCobraCommand

func CreateServerConfigForCobraCommand(cmd *cobra.Command) (*PlatformServerConfig, error)

CreateServerConfigForCobraCommand performs the same as CreateServerConfig but loads the flags to the provided cobra Command's *pflag.FlagSet instead of the global FlagSet instance.

type SpaConfig

type SpaConfig struct {
	RootFolder   string   `json:"root_folder"`   // location where Plank will serve SPA
	BaseUri      string   `json:"base_uri"`      // base URI for the SPA
	StaticAssets []string `json:"static_assets"` // locations for static assets used by the SPA
}

SpaConfig shorthand for SinglePageApplication Config is used to configure routes for your SPAs like Angular or React. for example if your app index.html is served at /app and static contents like JS/CSS are served from /app/static, BaseUri can be set to /app and StaticAssets to "/app/assets". see config.json for details.

func NewSpaConfig

func NewSpaConfig(input string) (spaConfig *SpaConfig, err error)

NewSpaConfig takes location to where the SPA content is as an input and returns a sanitized instance of *SpaConfig.

type TLSCertConfig

type TLSCertConfig struct {
	CertFile                  string `json:"cert_file"`                   // path to certificate file
	KeyFile                   string `json:"key_file"`                    // path to private key file
	SkipCertificateValidation bool   `json:"skip_certificate_validation"` // whether to skip certificate validation (useful for self-signed cert)
}

TLSCertConfig wraps around key information for TLS configuration

Jump to

Keyboard shortcuts

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