server

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MPL-2.0 Imports: 14 Imported by: 3

Documentation

Index

Constants

View Source
const DefaultHost = "0.0.0.0"
View Source
const DefaultPort = "9001"

Variables

View Source
var (
	PublicRoutes = []string{
		"/v1/featureflags",
	}
)

Functions

func AssetHandler added in v0.38.0

func AssetHandler(assetHandler, redirectHandler http.Handler) http.HandlerFunc

AssetHandler returns a http.Handler that serves static assets from the provided fs.FS. It also redirects all non-file requests to index.html.

func GetBaseHref added in v0.32.0

func GetBaseHref(routePrefix string) string

GetBaseHref formats the baseHref for the application given the configured route prefix. Its used to set the <base href> tag in the index.html file. This in turn will form the base URL for all the assets (js, css, etc) that are loaded by the browser.

The UI is built with Parcel and has been configured to generate relative script/link tags during the build (without a leading or trailing slash) e.g. <script src="main.js">. The base href we generate here must complete the URL for these assets and so should have a leading and trailing slash, e.g. <base href="/weave-gitops/"> or <base href="/">

func IndexHTMLHandler added in v0.38.0

func IndexHTMLHandler(fsys fs.FS, log logr.Logger, routePrefix string) http.HandlerFunc

IndexHTMLHandler ensures that index.html always gets served. The JS router will take care of actual navigation once the index.html page lands.

func InjectHTMLBaseTag added in v0.32.0

func InjectHTMLBaseTag(html []byte, baseHref string) []byte

InjectHTMLBaseTag injects a <base href> tag into the provided html. This is used to set the base URL for all the assets (js, css, etc) that are loaded by the browser.

func NewHandlers added in v0.6.0

func NewHandlers(ctx context.Context, log logr.Logger, cfg *Config, sm auth.SessionManager) (http.Handler, error)

NewHandlers creates and returns a new server configured to serve the core application.

func WithRoutePrefix added in v0.32.0

func WithRoutePrefix(mux *http.ServeMux, routePrefix string) *http.ServeMux

WithRoutePrefix wraps the provided mux with a new mux that handles the provided route prefix. This is useful when the application is served from a subpath, e.g. /weave-gitops. The route prefix is stripped from the request before being passed to the provided mux.

We also redirect the user to the route prefix if they hit the root of the server, e.g. if they port-forward.

Types

type ApplicationsOption added in v0.6.1

type ApplicationsOption func(*ApplicationsOptions)

ApplicationsOption defines the signature of a function that can be used to set an option for an ApplicationsServer.

func WithCRDFetcher added in v0.15.0

func WithCRDFetcher(fetcher crd.Fetcher) ApplicationsOption

WithCRDFetcher allows for setting a CRDFetcher.

func WithClientGetter added in v0.6.1

func WithClientGetter(clientGetter kube.ClientGetter) ApplicationsOption

WithClientGetter allows for setting a ClientGetter.

type ApplicationsOptions added in v0.6.1

type ApplicationsOptions struct {
	ClientGetter kube.ClientGetter
	CRDFetcher   crd.Fetcher
}

ApplicationsOptions includes all the options that can be set for an ApplicationsServer.

type Config added in v0.6.0

type Config struct {
	CoreServerConfig core.CoreServerConfig
	AuthServer       *auth.AuthServer
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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