router

package
v2.2.11 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package router is the main router and provides the main HTTP entry point for Platform.CC.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUpstreamNotFound is an error returned when a route upstream is not found.
	ErrUpstreamNotFound = errors.New("upstream not found")
)
View Source
var HTTPPort = uint16(80)

HTTPPort is the port to accept HTTP requests on.

View Source
var HTTPSPort = uint16(443)

HTTPSPort is the port to accept HTTPS requests on.

Functions

func AddProjectRoutes

func AddProjectRoutes(p *project.Project) error

AddProjectRoutes adds given project's routes to router.

func ClearCertificates

func ClearCertificates() error

ClearCertificates deletes all certificates files generates by minica.

func DeleteProjectRoutes

func DeleteProjectRoutes(p *project.Project) error

DeleteProjectRoutes deletes routes for given project.

func DumpCertificateCA

func DumpCertificateCA() ([]byte, error)

DumpCertificateCA returns the CA certificate.

func GenerateNginxConfig

func GenerateNginxConfig(proj *project.Project) ([]byte, error)

GenerateNginxConfig creates nginx configuration for given application.

func GenerateRouteListJSON

func GenerateRouteListJSON(proj *project.Project) ([]byte, error)

GenerateRouteListJSON creates a list of routes for project as JSON.

func GenerateTemplateVars

func GenerateTemplateVars(proj *project.Project) ([]map[string]interface{}, error)

GenerateTemplateVars generates variables to inject in nginx template.

func GetContainerConfig

func GetContainerConfig() container.Config

GetContainerConfig gets container configuration for the router.

func GetUpstreamHost

func GetUpstreamHost(proj *project.Project, upstream string, allowServices bool) (string, error)

GetUpstreamHost retrieves upstream hostname from upstream value in route.

func ListActiveProjects

func ListActiveProjects() ([]string, error)

ListActiveProjects returns list of project ids of projects current loaded in to the router.

func ListActiveRoutes

func ListActiveRoutes() ([]def.Route, error)

ListActiveRoutes returns list of routes currently active in the router.

func Reload

func Reload() error

Reload issues reload command to nginx in router container.

func Start

func Start() error

Start starts the router.

func Stop

func Stop() error

Stop stops the router.

Types

type HostRoute

type HostRoute struct {
	Host   string
	Routes []def.Route
}

HostRoute contains all routes mapped to a host.

func MapHostRoutes

func MapHostRoutes(routes []def.Route) []HostRoute

MapHostRoutes maps all routes to their hosts.

func (*HostRoute) AddRoute

func (h *HostRoute) AddRoute(r def.Route) bool

AddRoute adds a given route to the host map if its host matches.

Jump to

Keyboard shortcuts

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