Documentation ¶
Index ¶
- type CaddyTextUnmarshaler
- func (c *CaddyTextUnmarshaler[V, T, TP]) MarshalJSON() (text []byte, err error)
- func (c CaddyTextUnmarshaler[V, T, TP]) MarshalText() (text []byte, err error)
- func (c *CaddyTextUnmarshaler[V, T, TP]) UnmarshalJSON(text []byte) error
- func (c *CaddyTextUnmarshaler[V, T, TP]) UnmarshalText(text []byte) error
- func (c *CaddyTextUnmarshaler[V, T, TP]) Value() V
- type Hostname
- type IP
- type Port
- type UDPAddr
- type Value
- type ValueBool
- type ValueIP
- type ValueString
- type ValueUDPAddr
- type ValueUnsigned
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CaddyTextUnmarshaler ¶
type CaddyTextUnmarshaler[V, T any, TP valueConstraint[V, T]] struct { // contains filtered or unexported fields }
CaddyTextUnmarshaler is a generic struct for unmarshaling text into a value. It stores the unmarshaled value and the original text representation.
func (*CaddyTextUnmarshaler[V, T, TP]) MarshalJSON ¶
MarshalJSON marshals the CaddyTextUnmarshaler into JSON. It quotes the text if it's not valid JSON.
func (CaddyTextUnmarshaler[V, T, TP]) MarshalText ¶
MarshalText marshals the CaddyTextUnmarshaler back to text. It returns the original text representation.
func (*CaddyTextUnmarshaler[V, T, TP]) UnmarshalJSON ¶
UnmarshalJSON unmarshals JSON into the CaddyTextUnmarshaler's value. It handles JSON strings and unmarshals them as text.
func (*CaddyTextUnmarshaler[V, T, TP]) UnmarshalText ¶
UnmarshalText unmarshals text into the CaddyTextUnmarshaler's value. It uses Caddy's replacer for variable expansion in the text before unmarshaling.
func (*CaddyTextUnmarshaler[V, T, TP]) Value ¶
func (c *CaddyTextUnmarshaler[V, T, TP]) Value() V
Value returns the underlying value of the CaddyTextUnmarshaler.
type Hostname ¶
type Hostname = CaddyTextUnmarshaler[string, ValueString, *ValueString]
Hostname represents a unique hostname string. This type uses CaddyTextUnmarshaler with a string base type.
type IP ¶
IP is a type alias for handling IP addresses. It wraps the net.IP type and uses CaddyTextUnmarshaler for converting text-based IPv4 or IPv6 address representations into net.IP.
type Port ¶
type Port = CaddyTextUnmarshaler[uint16, ValueUnsigned[uint16], *ValueUnsigned[uint16]]
Port defines a network port value, which is an unsigned 16-bit integer. The validity of 0 as a port number depends on the specific use case or context.
type UDPAddr ¶
type UDPAddr = CaddyTextUnmarshaler[*net.UDPAddr, ValueUDPAddr, *ValueUDPAddr]
UDPAddr is a type alias for handling UDP network addresses. It wraps the net.UDPAddr type and utilizes CaddyTextUnmarshaler for parsing and handling UDP addresses in text form.
type Value ¶
type Value[V any] interface { encoding.TextUnmarshaler Value() V }
Value is an interface for types that can unmarshal text and return a value.
type ValueBool ¶
type ValueBool bool
ValueBool handles unmarshalling bool values.
func (*ValueBool) UnmarshalText ¶
UnmarshalText parses the bool with strconv.ParseBool internally.
type ValueIP ¶
ValueIP handles unmarshalling net.IP.
func (*ValueIP) UnmarshalText ¶
UnmarshalText implements the unmarshaling of text data into an IP address. It delegates to the encoding.TextUnmarshaler implementation of net.IP.
type ValueString ¶
type ValueString string
ValueString handles unmarshalling string values.
func (*ValueString) UnmarshalText ¶
func (s *ValueString) UnmarshalText(b []byte) error
UnmarshalText just sets the value to string(b).
func (*ValueString) Value ¶
func (s *ValueString) Value() string
Value returns the underlying string value of ValueString.
type ValueUDPAddr ¶
ValueUDPAddr handles unmarshalling a net.UDPAddr.
func (*ValueUDPAddr) UnmarshalText ¶
func (addr *ValueUDPAddr) UnmarshalText(text []byte) error
UnmarshalText implements the unmarshaling of text data into a UDP address. It resolves the text using net.ResolveUDPAddr.
func (*ValueUDPAddr) Value ¶
func (addr *ValueUDPAddr) Value() *net.UDPAddr
Value returns the underlying net.UDPAddr of ValueUDPAddr.
type ValueUnsigned ¶
type ValueUnsigned[N constraints.Unsigned] struct{ V N }
ValueUnsigned is a generic type for unmarshalling an unsigned number. N must be an unsigned type (e.g., uint, uint32).
func (*ValueUnsigned[N]) UnmarshalText ¶
func (n *ValueUnsigned[N]) UnmarshalText(b []byte) error
UnmarshalText parses the uint with strconv.ParseUint internally.
func (*ValueUnsigned[N]) Value ¶
func (n *ValueUnsigned[N]) Value() N
Value returns the underlying unsigned number of ValueUnsigned.