replacer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithReplacer

func WithReplacer(ctx context.Context, r Replacer) context.Context

WithReplacer returns a new context with a replacer instance

Types

type CtxKey

type CtxKey struct{}

CtxKey is used to store a replace instance in a context value

type Replacer

type Replacer interface {
	// Replace replaces all variables in string and returns the result
	Replace(string) string

	// Set adds a custom replacement value
	Set(key string, value Value)

	// Get returns the replacement value for key
	Get(key string) string
}

Replacer is capable of replacing variables in a template string

func GetReplacer

func GetReplacer(ctx context.Context) Replacer

GetReplacer returns the replacer associated with ctx

func NewReplacer

func NewReplacer(ctx context.Context, msg *dhcpv4.DHCPv4) Replacer

NewReplacer returns a new replacer instance for the given request message

type StringValue

type StringValue string

StringValue is a utility method to use string constants for the Value interface

func (StringValue) Get

func (s StringValue) Get(_ *dhcpv4.DHCPv4) string

Get implements the Value interface and returns s itself

type Value

type Value interface {
	// Get returns the string represenation for the given
	// msg
	Get(msg *dhcpv4.DHCPv4) string
}

Value is a getter for string represenations of custom DHCPv4 fields

Jump to

Keyboard shortcuts

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