nginxconf

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 5 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 nginxconf lexes and parses nginx configuration for the nginx plugin (routes) and the env plugin (the ${VAR} names an envsubst template reads). The syntax as nginx reads it: tokens separated by whitespace, a directive ends with ';', a block is { … }, "…" and '…' quote with backslash escapes, # starts a comment at the start of a token, and a ${…} inside a token is part of it (nginx's variable syntax), not a block.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsConfig

func IsConfig(p string) bool

IsConfig reports a file the shipped defaults call nginx configuration (files.nginx, path patterns).

Types

type Env

type Env struct {
	Name string
	Line int
}

Env is an environment variable a template reads, and its line.

func EnvNames

func EnvNames(src []byte) ([]Env, error)

EnvNames returns the ${VAR} names of an envsubst template (the official nginx image renders /etc/nginx/templates/*.template at start). Only the braced form is read: $host and the like are nginx's own variables. Comments are not tokens, so a name in a comment is not read.

type Node

type Node struct {
	Args  []Token // Args[0] is the directive's name
	Block []Node
	Open  bool // has a block
}

Node is one directive: its name and arguments, and its block when it has one.

func ParseFile

func ParseFile(file string, src []byte) ([]Node, error)

ParseFile lexes and parses one file; every token records the file.

func (Node) Line

func (n Node) Line() int

func (Node) Name

func (n Node) Name() string

func (Node) Values

func (n Node) Values() []string

Values returns the arguments' texts after the directive's name.

type Token

type Token struct {
	Text   string
	Line   int
	Quoted bool
	File   string // set by the caller after lexing (includes mix files)
}

Jump to

Keyboard shortcuts

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