hodhod

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Location string `json:"location"`
	FileExt  string `json:"file_ext"`
	Script   string `json:"script"`
}

type Cert

type Cert struct {
	CertFile string `json:"cert"`
	KeyFile  string `json:"key"`
}

type CgiError

type CgiError struct {
	ExitCode int
}

func (CgiError) Error

func (e CgiError) Error() string

type CgiResponse

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

func (*CgiResponse) Backend

func (resp *CgiResponse) Backend() string

func (*CgiResponse) Close

func (resp *CgiResponse) Close()

func (*CgiResponse) Init

func (resp *CgiResponse) Init(req *Request) (err error)

func (*CgiResponse) Read

func (resp *CgiResponse) Read(p []byte) (n int, err error)

type Config

type Config struct {
	ListenAddr   string             `json:"listen"`
	MatchOptions MatchOptionsConfig `json:"match_options"`
	CgiTimeout   int                `json:"cgi_timeout"`
	Routes       []Route            `json:"routes"`
	Backends     []Backend          `json:"backends"`
	Certs        []Cert             `json:"certs"`
	ContentType  ContentTypeConfig  `json:"content_type"`
}

func LoadConfig

func LoadConfig(configFilePath string) (config Config, err error)

func (*Config) GetBackendByName

func (cfg *Config) GetBackendByName(name string) *Backend

func (*Config) GetBackendByUrl

func (cfg *Config) GetBackendByUrl(u url.URL) (backend *Backend, unmatched string)

type ContentTypeConfig

type ContentTypeConfig struct {
	Default string            `json:"default"`
	ExtMap  map[string]string `json:"ext_map"`
}

type ErrorResponse

type ErrorResponse struct {
	StatusCode int
	Meta       string
	// contains filtered or unexported fields
}

func (*ErrorResponse) Backend

func (resp *ErrorResponse) Backend() string

func (*ErrorResponse) Close

func (resp *ErrorResponse) Close()

func (*ErrorResponse) Init

func (resp *ErrorResponse) Init(req *Request) (err error)

func (*ErrorResponse) Read

func (resp *ErrorResponse) Read(p []byte) (n int, err error)

type MatchOptionsConfig

type MatchOptionsConfig struct {
	QueryParams   string   `json:"query_params"`
	TrailingSlash string   `json:"trailing_slash"`
	DefaultExts   []string `json:"default_exts"`
	IndexFilename string   `json:"index_filename"`
}

type RedirectResponse

type RedirectResponse struct {
	StatusCode int
	Target     string
	// contains filtered or unexported fields
}

func (*RedirectResponse) Backend

func (resp *RedirectResponse) Backend() string

func (*RedirectResponse) Close

func (resp *RedirectResponse) Close()

func (*RedirectResponse) Init

func (resp *RedirectResponse) Init(req *Request) (err error)

func (*RedirectResponse) Read

func (resp *RedirectResponse) Read(p []byte) (n int, err error)

type Request

type Request struct {
	Url        *url.URL
	RemoteAddr string
}

type Response

type Response interface {
	// Called before response body is read, in order to perform any needed
	// initialization.
	Init(req *Request) (err error)

	// Read a part of the response body. Implementes the io.Reader interface.
	Read(p []byte) (n int, err error)

	// Release any resources related to this response
	Close()

	// Returns the backend name for this response
	Backend() string
}

func NewCgiResp

func NewCgiResp(req Request, scriptPath string, cfg *Config) (resp Response)

func NewFileResp

func NewFileResp(filename string, req Request, cfg *Config) (resp Response)

func NewPermRedirectResp

func NewPermRedirectResp(target string) (resp Response)

func NewTempRedirectResp

func NewTempRedirectResp(target string) (resp Response)

type Route

type Route struct {
	Prefix   string `json:"prefix"`
	Url      string `json:"url"`
	Hostname string `json:"hostname"`
	Backend  string `json:"backend"`
}

type StaticResponse

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

func (*StaticResponse) Backend

func (resp *StaticResponse) Backend() string

func (*StaticResponse) Close

func (resp *StaticResponse) Close()

func (*StaticResponse) Init

func (resp *StaticResponse) Init(req *Request) (err error)

func (*StaticResponse) Read

func (resp *StaticResponse) Read(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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