Documentation
¶
Index ¶
- func GetMimetypeFromPath(targetPath string) string
- func Template(file string, data interface{}) (string, error)
- type Context
- func (ctx *Context) BadRequest(info string)
- func (ctx *Context) CGIError(info string)
- func (ctx *Context) CertNotAuthorized(info string)
- func (ctx *Context) CertNotValid(info string)
- func (ctx *Context) ClientCertRequired(info string)
- func (ctx *Context) DelimInputAndDo(prompt string, delim string, handler MultiInputHandler)
- func (c *Context) GetParam(key string) (string, error)
- func (c *Context) GetParams() (url.Values, error)
- func (c *Context) GetQuery() string
- func (ctx *Context) Gone(info string)
- func (ctx *Context) Input(prompt string)
- func (ctx *Context) InputAndDo(prompt string, handler InputHandler)
- func (ctx *Context) NotFound(info string)
- func (ctx *Context) PermFailure(info string)
- func (ctx *Context) ProxyError(info string)
- func (ctx *Context) ProxyRequestRefused(info string)
- func (ctx *Context) RedirectPerm(url string)
- func (ctx *Context) RedirectTemp(url string)
- func (ctx *Context) SendBytes(mimeType string, content []byte)
- func (ctx *Context) SendFile(mimeType string, path string) error
- func (ctx *Context) SendString(mimeType string, str string)
- func (ctx *Context) SendStringf(mimeType string, str string, values ...interface{})
- func (ctx *Context) SendTemplate(mimeType string, path string, data interface{}) error
- func (ctx *Context) SensitiveInput(prompt string)
- func (ctx *Context) SensitiveInputAndDo(prompt string, handler InputHandler)
- func (ctx *Context) ServerUnavailable(info string)
- func (ctx *Context) SlowDown(waitSeconds int)
- func (ctx *Context) Success(mimeType string)
- func (ctx *Context) TempFail(info string)
- type InputHandler
- type LimitedConn
- type MultiInputHandler
- type Route
- type RouteHandler
- type Router
- type RouterOpts
- type Sandbox
- type Server
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMimetypeFromPath ¶
Types ¶
type Context ¶
func (*Context) BadRequest ¶
func (*Context) CertNotAuthorized ¶
func (*Context) CertNotValid ¶
func (*Context) ClientCertRequired ¶
func (*Context) DelimInputAndDo ¶ added in v0.3.1
func (ctx *Context) DelimInputAndDo(prompt string, delim string, handler MultiInputHandler)
Takes a multiple-value query, splits it on the delimiter, and passes the slice of values into the handler.
func (*Context) InputAndDo ¶
func (ctx *Context) InputAndDo(prompt string, handler InputHandler)
func (*Context) PermFailure ¶
func (*Context) ProxyError ¶
func (*Context) ProxyRequestRefused ¶
func (*Context) RedirectPerm ¶
func (*Context) RedirectTemp ¶
func (*Context) SendString ¶
func (*Context) SendStringf ¶
func (*Context) SendTemplate ¶ added in v0.3.0
func (*Context) SensitiveInput ¶
func (*Context) SensitiveInputAndDo ¶ added in v0.2.1
func (ctx *Context) SensitiveInputAndDo(prompt string, handler InputHandler)
func (*Context) ServerUnavailable ¶
type InputHandler ¶
type InputHandler func(string)
type LimitedConn ¶ added in v0.4.0
type LimitedConn struct { IP string Limiter *rate.Limiter Reservation *rate.Reservation }
Rate-limited connection. Stores the IP address, and the pointer to the rate-limiter it's associated with.
type MultiInputHandler ¶ added in v0.3.1
type MultiInputHandler func([]string)
type Route ¶
type Route struct { Path string Handler RouteHandler }
type RouteHandler ¶
type RouteHandler func(Context)
type Router ¶
type Router struct { Routes []Route Sandboxes []Sandbox ErrorHandler RouteHandler }
func BlankRouter ¶
func BlankRouter() Router
func NewRouter ¶
func NewRouter(config RouterOpts) Router
func (*Router) GetRouteHandler ¶
func (r *Router) GetRouteHandler(targetPath string) RouteHandler
Get the handler for a given route. If no route matches a handler, then return the default error handler.
func (*Router) Handle ¶ added in v0.3.3
func (r *Router) Handle(targetPath string, handler RouteHandler)
type RouterOpts ¶
type RouterOpts struct {
ErrorHandler RouteHandler
}
type Sandbox ¶
Sandboxes represent "static" file directories where having code execute upon URL visitation is not necessary.
type Server ¶
type Server struct { TLSConfig *tls.Config Router *Router Config ServerConfig }
func NewServer ¶
func NewServer(router *Router, config *ServerConfig) Server
type ServerConfig ¶ added in v0.4.0
type ServerConfig struct { // TLS certificate and key file paths. CertificatePath string KeyPath string // Self-explanatory. Hostname string Port uint16 // Whether connection logging should occur, // and where the file should be located. EnableLog bool LogFilePath string // This can be accessed during the server's lifetime to // manually write more info to the config, other than what's // built-in to Houston. LogFile *os.File // Whether the server should apply rate-limiting. EnableLimiting bool MaxRate rate.Limit BucketSize int // Example: file exists at `/page.gmi`, and user requests `/page`. Should // the server append the `.gmi` and return `/page.gmi`? This assumption will // happen before handler functions are checked. ImplyExtension bool }
Click to show internal directories.
Click to hide internal directories.