Help us shape the future of Go! Take the 2026 Go Developer Survey

marks

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package marks lets Zinc's own middleware tell Zinc what it needs at registration: to run before routing, such as rewrite, or to answer CORS preflight requests, such as cors. It's internal: nothing else can mark middleware.

Zinc asks a middleware by calling it with a probe, a Context whose request is Probe, and the middleware answers by returning its Marks as the error. Each instance answers for itself. Marks kept by code address would be shared by every closure a function makes, so marking one Skip wrapper would mark them all. Zinc probes only closures whose code is known to answer (see Answers), so no other middleware runs outside a request, and probes happen at registration, never per request.

Index

Constants

This section is empty.

Variables

View Source
var Probe = &http.Request{}

Probe is the request of the Context Zinc probes middleware with. No real request is ever this one.

View Source
var StaticDirectory func(c any, path string) bool

StaticDirectory reports whether a static mount of the app serving c, a *zinc.Context, serves path as a directory. Zinc sets it. A directory's URL ends with a slash, so trailingslash leaves such a path alone rather than loop with the directory's redirect.

Functions

func Answers

func Answers(mw any)

Answers records that closures with mw's code answer a probe. It's a fact about the code, not the instance: the instance decides what it answers. Call it on every instance a constructor returns; where the compiler inlines the constructor, a call site gets its own copy of the code.

func CanAnswer

func CanAnswer(mw any) bool

CanAnswer reports whether mw's code answers a probe, so it's safe to probe.

Types

type Marks

type Marks struct {
	// Prerouting names middleware that only works before routing, so it
	// can't be registered on a group.
	Prerouting string
	// Preflight is set on middleware that also answers CORS preflight
	// requests, so Zinc runs it on the automatic OPTIONS response.
	Preflight bool
}

Marks is a middleware's answer to a probe.

func (*Marks) Error

func (*Marks) Error() string

Jump to

Keyboard shortcuts

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