guard

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 6 Imported by: 1 module, 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 guard keeps the web pages of other sites away from the API: they could use the session cookie.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidOrigin = errors.New("origin must look like http://localhost:3000, with no path")

Functions

func CheckOrigin

func CheckOrigin(origin string) error

CheckOrigin refuses what could never match a browser Origin header: a trailing slash would silently block the web app.

func New

func New(origin string, next http.Handler) http.Handler

New lets through requests from origin, and those with no Origin at all (curl, scripts), which no web page can send to read or change anything. The Host check stops a domain pointed at 127.0.0.1 (DNS rebinding): its pages are same-origin for the browser, so they send no Origin on a GET.

Types

This section is empty.

Jump to

Keyboard shortcuts

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