caddyapi

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToHandlerName added in v0.2.7

func ToHandlerName(h interface{}) string

func URLFromID

func URLFromID(id string) string

URLFromID Converts an ID into it's resource URL "@config/apps/http" -> "/config/apps/http" "my_server/routes/0" -> "/id/my_server/routes/0"

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a Caddy API Client

func NewClient added in v0.1.1

func NewClient(host string, dial DialFunc) *Client

func NewUnixClient added in v0.2.6

func NewUnixClient(socket string, dial DialFunc) *Client

func (*Client) CreateHTTP

func (c *Client) CreateHTTP(http HTTP) error

CreateHTTP creates a new http app

func (*Client) CreateServer

func (c *Client) CreateServer(name string, server Server) (string, error)

CreateServer creates a http server

func (*Client) DeleteHTTP

func (c *Client) DeleteHTTP() error

func (*Client) DeleteServer

func (c *Client) DeleteServer(id string) error

func (*Client) EnforceExists

func (c *Client) EnforceExists(id string) error

EnforceExists ensures that the path exists. If it doesn't currently exist, it sets it to be empty

func (*Client) GetHTTP

func (c *Client) GetHTTP() (*HTTP, error)

func (*Client) GetServer

func (c *Client) GetServer(id string) (*Server, error)

func (*Client) UpdateHTTPGracePeriod

func (c *Client) UpdateHTTPGracePeriod(gracePeriod Duration) error

func (*Client) UpdateHTTPPort

func (c *Client) UpdateHTTPPort(httpPort int) error

func (*Client) UpdateHTTPSPort

func (c *Client) UpdateHTTPSPort(httpsPort int) error

func (*Client) UpdateServerListen

func (c *Client) UpdateServerListen(id string, listen []string) error

func (*Client) UpdateServerRoutes added in v0.2.0

func (c *Client) UpdateServerRoutes(id string, routes []Route) error

type DialFunc added in v0.2.6

type DialFunc = func(network, addr string) (net.Conn, error)

type Duration

type Duration time.Duration

Duration is a wrapper around time.Duration with appropriate text unmarshal func

func (Duration) String

func (d Duration) String() string

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(s string) error

UnmarshalText converts `3.5s` and similar strings into the correct duration value

type FileServer added in v0.2.7

type FileServer struct {
	Root          string   `json:"root,omitempty"`
	Hide          []string `json:"hide,omitempty"`
	IndexNames    []string `json:"index_names,omitempty"`
	CanonicalURIs bool     `json:"canonical_uris,omitempty"`
	PassThru      bool     `json:"pass_thru,omitempty"`
}

type HTTP

type HTTP struct {
	HTTPPort    int      `json:"http_port"`
	HTTPSPort   int      `json:"https_port"`
	GracePeriod Duration `json:"grace_period"`
}

HTTP is the representation of the Caddy HTTP App

type HandleMarshal added in v0.2.7

type HandleMarshal struct {
	Handle interface{}
}

func (*HandleMarshal) FromHandlerName added in v0.2.7

func (s *HandleMarshal) FromHandlerName(h string, b []byte) error

func (HandleMarshal) MarshalJSON added in v0.2.7

func (s HandleMarshal) MarshalJSON() ([]byte, error)

func (*HandleMarshal) UnmarshalJSON added in v0.2.7

func (s *HandleMarshal) UnmarshalJSON(b []byte) error

type Match

type Match struct {
	ID     string              `json:"@id,omitempty"`
	Host   []string            `json:"host,omitempty"`
	Path   []string            `json:"path,omitempty"`
	Method []string            `json:"method,omitempty"`
	Header map[string][]string `json:"header,omitempty"`
	Query  map[string][]string `json:"query,omitempty"`
	Not    []Match             `json:"not,omitempty"`
}

Match represents the Caddy Match object https://caddyserver.com/docs/json/apps/http/servers/routes/match/

type RequestBody added in v0.2.7

type RequestBody struct {
	MaxSize int `json:"max_size"`
}

type ReverseProxy added in v0.2.7

type ReverseProxy struct {
	Upstreams []Upstream `json:"upstreams"`
}

type Route

type Route struct {
	ID       string          `json:"@id,omitempty"`
	Group    string          `json:"group,omitempty"`
	Matchers []Match         `json:"match,omitempty"`
	Handlers []HandleMarshal `json:"handle,omitempty"`
	Terminal bool            `json:"terminal,omitempty"`
}

Route represents the Caddy Route object https://caddyserver.com/docs/json/apps/http/servers/routes/

type Server

type Server struct {
	ID     string         `json:"@id,omitempty"`
	Listen []string       `json:"listen"`
	Routes []Route        `json:"routes"`
	Errors *ServerErrors  `json:"errors"`
	Logs   *ServerLogging `json:"logs"`
}

Server represents the Caddy Server object https://caddyserver.com/docs/json/apps/http/servers/

type ServerErrors added in v0.2.5

type ServerErrors struct {
	Routes []Route `json:"routes,omitempty"`
}

type ServerLogging added in v0.2.5

type ServerLogging struct {
	DefaultLoggerName string            `json:"default_logger_name,omitempty"`
	LoggerNames       map[string]string `json:"logger_names,omitempty"`
	SkipHosts         []string          `json:"skip_hosts,omitempty"`
	SkipUnmappedHosts bool              `json:"skip_unmapped_hosts,omitempty"`
}

type StaticResponse added in v0.2.7

type StaticResponse struct {
	StatusCode string              `json:"status_code,omitempty"`
	Headers    map[string][]string `json:"headers,omitempty"`
	Body       string              `json:"body,omitempty"`
	Close      bool                `json:"close,omitempty"`
}

type StatusError

type StatusError struct {
	// contains filtered or unexported fields
}

StatusError is the error returned when Request responds with non-2XX

func (StatusError) Error

func (s StatusError) Error() string

type Subroute added in v0.2.7

type Subroute struct {
	Routes []Route       `json:"routes"`
	Errors *ServerErrors `json:"errors"`
}

type Templates added in v0.2.7

type Templates struct {
	FileRoot   string   `json:"file_root,omitempty"`
	MimeTypes  []string `json:"mime_types,omitempty"`
	Delimiters []string `json:"delimiters,omitempty"`
}

type Upstream

type Upstream struct {
	Dial string `json:"dial"`
}

Jump to

Keyboard shortcuts

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