Documentation ¶
Index ¶
- Variables
- func AddServerIDHandler(next http.Handler, serverID string) http.Handler
- func BasicAuthHandler(next http.Handler, username, password string) http.Handler
- func CgitHandler(path, uri string) http.Handler
- func CompressHandler(handler http.Handler) http.Handler
- func FileOrDirHandler(path, uri string) http.Handler
- func GetWindowAndTree(arg string) (window, tree string, err error)
- func GitHandler(path, uri string) http.Handler
- func GzHandler(next http.Handler, clevel string) http.Handler
- func HasQueryParam(key string, vals url.Values) bool
- func LocalFilename(fileURL *url.URL) string
- func LogRequestHandler(handler http.Handler, logWriter io.Writer) http.Handler
- func MyIPHandler() http.Handler
- func NoCacheHandler(next http.Handler) http.Handler
- func QrHandler(content string) http.Handler
- func RedirectHandler(path, location string) http.Handler
- func ServeFileHandler(name string) http.Handler
- func ServeStringHandler(str string) http.Handler
- func SetContentType(next http.Handler, contentType string) http.Handler
- func TarHandler(dir, prefix string) http.Handler
- func UploadHandler(dir string) http.Handler
- func ZipDirectory(w io.Writer, dir, prefix string, store bool) error
- func ZipFSHandler(name, prefix, index string) http.Handler
- func ZipHandler(dir, prefix string, store bool) http.Handler
- type OnetimeTLS
- type Opts
Constants ¶
This section is empty.
Variables ¶
var ( Version = "dev-build" GitHash = "" BuildDate = "" )
Functions ¶
func AddServerIDHandler ¶
addServerIDHandler adds "Server: <serverID>" to the response header
func BasicAuthHandler ¶
basicAuthHandler checks the submited username and password against predefined values.
func CgitHandler ¶
cgitHandler will call "cgit" via /uri:cgit://path/to/dir. "cgit" uses a configuration file given via the environment variable CGIT_CONFIG. if that file is not given, a simple one is created for the user. that created file is deleted when **knut** shuts down. it's main purpose is to set the scan-path directive to "." which makes cgit scan the directory given via the uri. if the user places a "cgitrc" file into the .git folder of a scanned git-repo, the "repo.*" options are applied there. eg,
knut.git/.git/cgitrc desc=knut - throws trees out of windows
will make that directory be listed with that description.
func CompressHandler ¶
compressHandler requests having Accept-Encoding 'deflate' or 'gzip' taken from https://github.com/gorilla/handlers/blob/master/compress.go
func FileOrDirHandler ¶
func GetWindowAndTree ¶
getWindowAndTree splits "arg" at the ':' separator. in the context of *knut* the first part is called "window" (it is the url-endpoint, essentially), the part after the first ':' is called "the tree", it's the content that will be delivered.
func GitHandler ¶
gitHandler serves the given directory via "git http-backend". the advantage of using "git http-backend" is that it supports the more clever way of offering a git repository (opposite to the dumb http-protocol also possible)
func LocalFilename ¶
func LogRequestHandler ¶
logRequestHandler returns a handler which logs all requests to 'writer'. it also captures the status-code
func MyIPHandler ¶
myIPHandler yells back the remote IP to the browser
func NoCacheHandler ¶
noCacheHandler adds a 'nocaching, please' hint to the response header
func RedirectHandler ¶
func ServeFileHandler ¶
serveFileHandler serves the file given by 'name'
func ServeStringHandler ¶
serveStringHandler writes given 'str' to the response
func SetContentType ¶
setContentType sets the "Content-Type" to "contentType", if not already set
func TarHandler ¶
tarHandler creates a tar-archive from 'dir' on the fly and writes it to 'w'
func UploadHandler ¶
uploadHandler handles uploads to a given 'dir'. for method "GET" an upload-form is rendered, "POST" handles the actual upload
func ZipDirectory ¶
zipDirectory creates a .zip from "dir" and writes it to "w". it also prepends "prefix" to each name.
func ZipFSHandler ¶
zipFSHandler provides access to the contents of the .zip file specified by "name".
if "prefix" is applied to all requests, eg: a "/foo/bar" request is tried to find as "/prefix/foo/bar" in the zip file.
if the requested path is a folder, use the "index" in that folder to to render the folder entries.
Types ¶
type OnetimeTLS ¶
func (*OnetimeTLS) Create ¶
func (ot *OnetimeTLS) Create(addr string) error
create an in-memory root-certificate, sign it with an in-memory private key (elliptic curve521), and create a tlsListener based upon that certificate. it's only purpose is to have a tls-cert with a onetime, throw-away certificate. fyi: http://safecurves.cr.yp.to/