routing

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TrackSession

func TrackSession(res http.ResponseWriter, session *models.Session)

TrackSession adds the session tracking cookie to the HTTP response

func UntrackSession

func UntrackSession(res http.ResponseWriter)

UntrackSession removes the session tracking cookie from the HTTP response

Types

type ForwardRules

type ForwardRules func(w http.ResponseWriter, r *http.Request) (http.ResponseWriter, *http.Request)

ForwardRules defines a set of rules applied to a proxied request A ruleset is composed of change to http headers and url rewrites.

func BuildDefaultForwardRules

func BuildDefaultForwardRules(conf *models.ApplicationConfiguration, variables models.Variables) (ForwardRules, error)

BuildDefaultForwardRules builds the rule set given the application configuration

type Handler

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

func NewHandler

func NewHandler(environment utils.Environment, proxy *proxy.Handler, sessionStorage *storage.Session, applicationStorage *storage.Application, query *services.QueryService, request *services.RequestService, static *services.StaticService) *Handler

NewHandler creates new routing handler

func (*Handler) RouteReverseProxyRequests

func (h *Handler) RouteReverseProxyRequests() http.Handler

RouteReverseProxyRequests handles the routing to the right backend service. Each service is backed by a session, so we try to find the corresponding session.

In dev mode this function checks if the request path is part of the frontend and serves the request proxying it to the webpack-dev-server.

The session retrieval depends on the session tracking cookie value stored in the request object. If the session UUID stored in the cookie is valid, this router serves the backend service.

If a request URL has a special "smart url" pattern (i.e. /s/<checkout>/<path>) the request is considered to be a redirect to a specific session identified by its checkout, in a specific path. The session tracking cookie value is thus skipped.

Smart urls detection takes precedence over evaluation of session tracking cookie value.

Jump to

Keyboard shortcuts

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