origins

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package origins reads the browser origins: the CORS settings every environment shares and, for each environment, its hosts and the browser origins it admits. They are written in the proxyfile, or in an origins file it names.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PatternRegex

func PatternRegex(pattern string) string

PatternRegex keeps the meaning a Spring allowed-origin-pattern has: every character literal but *, which matches any run, dots included.

func SameOriginRegex

func SameOriginRegex(host string) string

SameOriginRegex admits the service's own origin on one of its hosts, on either scheme and any port.

Types

type CORS

type CORS struct{ AllowMethods, AllowHeaders, ExposeHeaders, MaxAge string } // "" when not written

type Environment

type Environment struct {
	Name                     string
	Hosts, Origins, Patterns []string  // nil when not written or empty
	Pos                      model.Pos // the environment's mapping in an origins file; its key in the proxyfile
}

type File

type File struct {
	CORS         CORS
	Environments []Environment // written order
}

File is the origins after reading, from either place, with every rule below checked.

func Inline added in v1.1.0

func Inline(cors, environments *tree.Node) (*File, []model.Problem)

Inline reads the origins written in the proxyfile: environments is its origins mapping, which the format check accepted, and cors its cors mapping, or nil when not written. Each entry is one environment, named by its key.

func Read

func Read(path string) (*File, []model.Problem)

Read reads the origins file at path, which is JSON read as YAML so that a problem names its line. It returns the problems of the first step that finds any: reading the file, its syntax, the format check, then the rules below.

Jump to

Keyboard shortcuts

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