routing

package
v0.0.0-...-c486877 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MIT Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitCSRFMiddlware

func InitCSRFMiddlware(csrfAuthKey []byte, secure bool, path string, cookieName string) func(http.Handler) http.Handler

func InitHealthRouting

func InitHealthRouting(serverName string, appCtx appcontext.AppContext, redisPool *redis.Pool,
	routingConfig *Config, telemetryConfig *telemetry.Config) (http.Handler, error)

InitHealthRouting sets up the routing for the internal health server used by the ECS health check

func InitRouting

func InitRouting(serverName string, appCtx appcontext.AppContext, redisPool *redis.Pool,
	routingConfig *Config, telemetryConfig *telemetry.Config) (http.Handler, error)

InitRouting sets up the routing for all the hosts (mil, office, admin, api)

Types

type BaseRoutingSuite

type BaseRoutingSuite struct {
	handlers.BaseHandlerTestSuite
	// contains filtered or unexported fields
}

func NewBaseRoutingSuite

func NewBaseRoutingSuite() BaseRoutingSuite

func (*BaseRoutingSuite) CreateFileWithContent

func (suite *BaseRoutingSuite) CreateFileWithContent(fpath string, fcontent string)

func (*BaseRoutingSuite) EqualDefaultIndex

func (suite *BaseRoutingSuite) EqualDefaultIndex(rr *httptest.ResponseRecorder)

EqualDefaultIndex compares the response and ensures it has been served by the default index handler

func (*BaseRoutingSuite) EqualServerName

func (suite *BaseRoutingSuite) EqualServerName(actualServerName string)

func (*BaseRoutingSuite) HandlerConfig

func (suite *BaseRoutingSuite) HandlerConfig() handlers.HandlerConfig

override HandlerConfig to use the version saved in routing config so the same session manager(s) are used

func (*BaseRoutingSuite) NewAdminRequest

func (suite *BaseRoutingSuite) NewAdminRequest(method string, relativePath string, body io.Reader) *http.Request

func (*BaseRoutingSuite) NewAuthenticatedAdminRequest

func (suite *BaseRoutingSuite) NewAuthenticatedAdminRequest(method string, relativePath string, body io.Reader, adminUser models.AdminUser) *http.Request

func (*BaseRoutingSuite) NewAuthenticatedMilRequest

func (suite *BaseRoutingSuite) NewAuthenticatedMilRequest(method string, relativePath string, body io.Reader, serviceMember models.ServiceMember) *http.Request

func (*BaseRoutingSuite) NewAuthenticatedOfficeRequest

func (suite *BaseRoutingSuite) NewAuthenticatedOfficeRequest(method string, relativePath string, body io.Reader, officeUser models.OfficeUser) *http.Request

func (*BaseRoutingSuite) NewAuthenticatedPPTASRequest

func (suite *BaseRoutingSuite) NewAuthenticatedPPTASRequest(method string, relativePath string, body io.Reader, clientCert models.ClientCert) *http.Request

func (*BaseRoutingSuite) NewAuthenticatedPrimeRequest

func (suite *BaseRoutingSuite) NewAuthenticatedPrimeRequest(method string, relativePath string, body io.Reader, clientCert models.ClientCert) *http.Request

the authentication.DevLocalPrimeMiddleware checks for the existence of a particular hash, so ensure that hash exists in the db and is associated with a user

func (*BaseRoutingSuite) NewMilRequest

func (suite *BaseRoutingSuite) NewMilRequest(method string, relativePath string, body io.Reader) *http.Request

func (*BaseRoutingSuite) NewOfficeRequest

func (suite *BaseRoutingSuite) NewOfficeRequest(method string, relativePath string, body io.Reader) *http.Request

func (*BaseRoutingSuite) NewPPTASRequest

func (suite *BaseRoutingSuite) NewPPTASRequest(method string, relativePath string, body io.Reader) *http.Request

func (*BaseRoutingSuite) NewPrimeRequest

func (suite *BaseRoutingSuite) NewPrimeRequest(method string, relativePath string, body io.Reader) *http.Request

func (*BaseRoutingSuite) NewRequest

func (suite *BaseRoutingSuite) NewRequest(method string, hostname string, relativePath string, body io.Reader) *http.Request

func (*BaseRoutingSuite) NewTLSAuthenticatedPrimeRequest

func (suite *BaseRoutingSuite) NewTLSAuthenticatedPrimeRequest(method string, relativePath string, body io.Reader) *http.Request

The ClientCertMiddleware looks at the TLS certificate on the request to make sure it matches something in the database. Fake the TLS info on the request

func (*BaseRoutingSuite) RoutingConfig

func (suite *BaseRoutingSuite) RoutingConfig() *Config

func (*BaseRoutingSuite) SetupAdminRequestSession

func (suite *BaseRoutingSuite) SetupAdminRequestSession(req *http.Request, adminUser models.AdminUser)

func (*BaseRoutingSuite) SetupCustomSiteHandler

func (suite *BaseRoutingSuite) SetupCustomSiteHandler(routingConfig *Config) http.Handler

func (*BaseRoutingSuite) SetupCustomSiteHandlerWithTelemetry

func (suite *BaseRoutingSuite) SetupCustomSiteHandlerWithTelemetry(routingConfig *Config, telemetryConfig *telemetry.Config) http.Handler

func (*BaseRoutingSuite) SetupMilRequestSession

func (suite *BaseRoutingSuite) SetupMilRequestSession(req *http.Request, serviceMember models.ServiceMember)

func (*BaseRoutingSuite) SetupOfficeRequestSession

func (suite *BaseRoutingSuite) SetupOfficeRequestSession(req *http.Request, officeUser models.OfficeUser)

func (*BaseRoutingSuite) SetupSiteHandler

func (suite *BaseRoutingSuite) SetupSiteHandler() http.Handler

type Config

type Config struct {
	HandlerConfig handlers.HandlerConfig

	AuthContext authentication.Context

	// Use the afero filesystem interface to allow for replacement
	// during testing
	FileSystem afero.Fs

	// BuildRoot is where the client build is located (e.g. "build")
	BuildRoot string

	// If running in local development mode, where should uploaded
	// files be stored? LocalStorageRoot and LocalStorageWebRoot
	// configure that
	LocalStorageRoot    string
	LocalStorageWebRoot string

	// What is the maximum body size that should be accepted?
	MaxBodySize int64

	// Should serve client collector endpoint?
	ServeClientCollector bool

	// Should the swagger ui be served? Generally only enabled in development
	ServeSwaggerUI bool

	// Should the orders api be served? This is deprecated now
	ServeOrders bool
	// The path to the orders api swagger definition
	OrdersSwaggerPath string

	// Should the prime api be served?
	ServePrime bool
	// The path to the prime api swagger definition
	PrimeSwaggerPath string
	// The path to the prime V2 api swagger definition
	PrimeV2SwaggerPath string
	// The path to the prime V3 api swagger definition
	PrimeV3SwaggerPath string

	// Should the support api be served? Mostly only used in dev environments
	ServeSupport bool
	// The path to the support api swagger definition
	SupportSwaggerPath string

	// Should the API endpoint for profiling be enabled. Mostly only
	// used in dev environments
	ServeDebugPProf bool

	// Should the internal api be served?
	ServeAPIInternal bool
	// The path to the internal api swagger definition
	APIInternalSwaggerPath string

	// Should the admin api be served?
	ServeAdmin bool
	// The path to the admin api swagger definition
	AdminSwaggerPath string

	// Should the prime simulator be enabled? Definitely never enabled
	// in production
	ServePrimeSimulator bool

	// Should the ghc api be served?
	ServeGHC bool
	// The path to the ghc api swagger definition
	GHCSwaggerPath string

	// Should the pptas api be served?
	ServePPTAS bool
	// The path to the pptas api swagger definition
	PPTASSwaggerPath string

	// Should devlocal auth be enabled? Definitely never enabled in
	// production
	ServeDevlocalAuth bool

	// The git branch and commit used when building this server
	GitBranch string
	GitCommit string

	// To prevent CSRF, configure a CSRF Middlware
	// Configuring it here lets us re-use it / override it effectively
	// in tests
	CSRFMiddleware func(http.Handler) http.Handler
}

type HostRouter

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

a custom host router that ignores the port

func NewHostRouter

func NewHostRouter() *HostRouter

func (*HostRouter) Map

func (hr *HostRouter) Map(host string, r chi.Router)

Map adds a chi.Router for a hostname

func (*HostRouter) Match

func (hr *HostRouter) Match(_ *chi.Context, _ string, _ string) bool

func (*HostRouter) Middlewares

func (hr *HostRouter) Middlewares() chi.Middlewares

The HostRouter does not support setting up middleware for all hosts, it should be done on a per host basis using the chi.Router added via Map. Thus the host router always has empty middleware

func (*HostRouter) Routes

func (hr *HostRouter) Routes() []chi.Route

The HostRouter does not use chi.Route as mentioned in Match, and so the list of routes is always empty

func (*HostRouter) ServeHTTP

func (hr *HostRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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