caddyfile

package
v2.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Process

func Process(caddyfileContent []byte) ([]byte, []byte)

Process caddyfile and removes wrong server blocks

Types

type Block

type Block struct {
	*Container
	Order int
	Keys  []string
}

Block can represent any of those caddyfile elements: - GlobalOptions - Snippet - Site - MatcherDefinition - Option - Directive - Subdirective

It's structure is rendered in caddyfile as: Keys[0] Keys[1] Keys[2]

When children are defined, each child is also recursively rendered as:

Keys[0] Keys[1] Keys[2] {
	Children[0].Keys[0] Children[0].Keys[1]
	Children[1].Keys[0] Children[1].Keys[1]
}

func CreateBlock

func CreateBlock() *Block

CreateBlock creates a block

func (*Block) AddKeys

func (block *Block) AddKeys(keys ...string)

AddKeys to block

func (*Block) GetFirstKey

func (block *Block) GetFirstKey() string

GetFirstKey from block

func (*Block) IsGlobalBlock

func (block *Block) IsGlobalBlock() bool

IsGlobalBlock returns if block is a global block

func (*Block) IsMatcher

func (block *Block) IsMatcher() bool

IsMatcher returns if block is a matcher

func (*Block) IsSnippet

func (block *Block) IsSnippet() bool

IsSnippet returns if block is a snippet

func (*Block) Marshal

func (block *Block) Marshal() []byte

Marshal block into caddyfile bytes

type Container

type Container struct {
	Children []*Block
}

Container represents a collection of blocks

func CreateContainer

func CreateContainer() *Container

CreateContainer creates a container

func FromLabels

func FromLabels(labels map[string]string, templateData interface{}, templateFuncs template.FuncMap) (*Container, error)

FromLabels converts key value labels into a caddyfile

func Unmarshal

func Unmarshal(caddyfileContent []byte) (*Container, error)

Unmarshal a Block fom caddyfile content

func (*Container) AddBlock

func (container *Container) AddBlock(block *Block)

AddBlock to container

func (*Container) GetAllByFirstKey

func (container *Container) GetAllByFirstKey(firstKey string) []*Block

GetAllByFirstKey gets all blocks with the specified firstKey

func (*Container) Marshal

func (container *Container) Marshal() []byte

Marshal container into caddyfile bytes

func (*Container) Merge

func (containerA *Container) Merge(containerB *Container)

Merge a second caddyfile container into this container

func (*Container) Remove

func (container *Container) Remove(blockToDelete *Block)

Remove removes a specific block

type Token

type Token struct {
	File string
	Line int
	Text string
}

Token represents a single parsable unit.

Jump to

Keyboard shortcuts

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