gatepath

package
v0.96.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package gatepath decides whether a request path sits under one of the path prefixes a loopback host's session gate lets through (battery/service and battery/desktop Config.OpenPrefixes).

The match is deliberately narrow. A path the router could resolve to something other than what the gate saw is never open:

  • a path that is not already clean ("/api/../admin", "/api//x"), because a router that cleans it serves a different route;
  • a path with any percent-encoded byte (r.URL.RawPath set: "/api%2Fx"), because a router that matches on the escaped path sees different segments than the decoded one;
  • a prefix match that is not on a segment boundary ("/apix" is not under "/api").

A request this package refuses stays behind the gate, so every mistake fails closed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(r *http.Request, prefixes []string) bool

Open reports whether r's path is prefix itself or below it, for one of prefixes. See the package doc for the paths it refuses.

func Validate

func Validate(field, prefix string) error

Validate refuses a prefix the gate cannot match safely: one that is not an absolute clean path of plain segments, "/" (which would be the whole app, and there is no switch for that), and anything under /__gofastr/, which holds the framework's own runtime, SSE and sign-in routes. field names the setting in the error ("service: Config.OpenPrefixes").

Types

This section is empty.

Jump to

Keyboard shortcuts

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