id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
124,900
mholt/caddy
caddyhttp/gzip/requestfilter.go
ShouldCompress
func (e ExtFilter) ShouldCompress(r *http.Request) bool { ext := path.Ext(r.URL.Path) return e.Exts.Contains(ExtWildCard) || e.Exts.Contains(ext) }
go
func (e ExtFilter) ShouldCompress(r *http.Request) bool { ext := path.Ext(r.URL.Path) return e.Exts.Contains(ExtWildCard) || e.Exts.Contains(ext) }
[ "func", "(", "e", "ExtFilter", ")", "ShouldCompress", "(", "r", "*", "http", ".", "Request", ")", "bool", "{", "ext", ":=", "path", ".", "Ext", "(", "r", ".", "URL", ".", "Path", ")", "\n", "return", "e", ".", "Exts", ".", "Contains", "(", "ExtWi...
// ShouldCompress checks if the request file extension matches any // of the registered extensions. It returns true if the extension is // found and false otherwise.
[ "ShouldCompress", "checks", "if", "the", "request", "file", "extension", "matches", "any", "of", "the", "registered", "extensions", ".", "It", "returns", "true", "if", "the", "extension", "is", "found", "and", "false", "otherwise", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/gzip/requestfilter.go#L56-L59
124,901
mholt/caddy
caddyhttp/gzip/requestfilter.go
ShouldCompress
func (p PathFilter) ShouldCompress(r *http.Request) bool { return !p.IgnoredPaths.ContainsFunc(func(value string) bool { return httpserver.Path(r.URL.Path).Matches(value) }) }
go
func (p PathFilter) ShouldCompress(r *http.Request) bool { return !p.IgnoredPaths.ContainsFunc(func(value string) bool { return httpserver.Path(r.URL.Path).Matches(value) }) }
[ "func", "(", "p", "PathFilter", ")", "ShouldCompress", "(", "r", "*", "http", ".", "Request", ")", "bool", "{", "return", "!", "p", ".", "IgnoredPaths", ".", "ContainsFunc", "(", "func", "(", "value", "string", ")", "bool", "{", "return", "httpserver", ...
// ShouldCompress checks if the request path matches any of the // registered paths to ignore. It returns false if an ignored path // is found and true otherwise.
[ "ShouldCompress", "checks", "if", "the", "request", "path", "matches", "any", "of", "the", "registered", "paths", "to", "ignore", ".", "It", "returns", "false", "if", "an", "ignored", "path", "is", "found", "and", "true", "otherwise", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/gzip/requestfilter.go#L70-L74
124,902
mholt/caddy
caddyhttp/gzip/requestfilter.go
Contains
func (s Set) Contains(value string) bool { _, ok := s[value] return ok }
go
func (s Set) Contains(value string) bool { _, ok := s[value] return ok }
[ "func", "(", "s", "Set", ")", "Contains", "(", "value", "string", ")", "bool", "{", "_", ",", "ok", ":=", "s", "[", "value", "]", "\n", "return", "ok", "\n", "}" ]
// Contains check if the set contains value.
[ "Contains", "check", "if", "the", "set", "contains", "value", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/gzip/requestfilter.go#L90-L93
124,903
mholt/caddy
caddyhttp/gzip/requestfilter.go
ContainsFunc
func (s Set) ContainsFunc(f func(string) bool) bool { for k := range s { if f(k) { return true } } return false }
go
func (s Set) ContainsFunc(f func(string) bool) bool { for k := range s { if f(k) { return true } } return false }
[ "func", "(", "s", "Set", ")", "ContainsFunc", "(", "f", "func", "(", "string", ")", "bool", ")", "bool", "{", "for", "k", ":=", "range", "s", "{", "if", "f", "(", "k", ")", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", ...
// ContainsFunc is similar to Contains. It iterates all the // elements in the set and passes each to f. It returns true // on the first call to f that returns true and false otherwise.
[ "ContainsFunc", "is", "similar", "to", "Contains", ".", "It", "iterates", "all", "the", "elements", "in", "the", "set", "and", "passes", "each", "to", "f", ".", "It", "returns", "true", "on", "the", "first", "call", "to", "f", "that", "returns", "true", ...
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/gzip/requestfilter.go#L98-L105
124,904
mholt/caddy
sigtrap.go
allShutdownCallbacks
func allShutdownCallbacks() []error { var errs []error instancesMu.Lock() for _, inst := range instances { errs = append(errs, inst.ShutdownCallbacks()...) } instancesMu.Unlock() return errs }
go
func allShutdownCallbacks() []error { var errs []error instancesMu.Lock() for _, inst := range instances { errs = append(errs, inst.ShutdownCallbacks()...) } instancesMu.Unlock() return errs }
[ "func", "allShutdownCallbacks", "(", ")", "[", "]", "error", "{", "var", "errs", "[", "]", "error", "\n", "instancesMu", ".", "Lock", "(", ")", "\n", "for", "_", ",", "inst", ":=", "range", "instances", "{", "errs", "=", "append", "(", "errs", ",", ...
// allShutdownCallbacks executes all the shutdown callbacks // for all the instances, and returns all the errors generated // during their execution. An error executing one shutdown // callback does not stop execution of others. Only one shutdown // callback is executed at a time.
[ "allShutdownCallbacks", "executes", "all", "the", "shutdown", "callbacks", "for", "all", "the", "instances", "and", "returns", "all", "the", "errors", "generated", "during", "their", "execution", ".", "An", "error", "executing", "one", "shutdown", "callback", "doe...
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/sigtrap.go#L96-L104
124,905
mholt/caddy
caddyhttp/httpserver/tplcontext.go
Include
func (c Context) Include(filename string, args ...interface{}) (string, error) { c.Args = args return ContextInclude(filename, c, c.Root) }
go
func (c Context) Include(filename string, args ...interface{}) (string, error) { c.Args = args return ContextInclude(filename, c, c.Root) }
[ "func", "(", "c", "Context", ")", "Include", "(", "filename", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "c", ".", "Args", "=", "args", "\n", "return", "ContextInclude", "(", "filename", ",", "c",...
// Include returns the contents of filename relative to the site root.
[ "Include", "returns", "the", "contents", "of", "filename", "relative", "to", "the", "site", "root", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/tplcontext.go#L65-L68
124,906
mholt/caddy
caddyhttp/httpserver/tplcontext.go
Now
func (c Context) Now(format string) string { return time.Now().Format(format) }
go
func (c Context) Now(format string) string { return time.Now().Format(format) }
[ "func", "(", "c", "Context", ")", "Now", "(", "format", "string", ")", "string", "{", "return", "time", ".", "Now", "(", ")", ".", "Format", "(", "format", ")", "\n", "}" ]
// Now returns the current timestamp in the specified format.
[ "Now", "returns", "the", "current", "timestamp", "in", "the", "specified", "format", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/tplcontext.go#L71-L73
124,907
mholt/caddy
caddyhttp/httpserver/tplcontext.go
Cookie
func (c Context) Cookie(name string) string { cookies := c.Req.Cookies() for _, cookie := range cookies { if cookie.Name == name { return cookie.Value } } return "" }
go
func (c Context) Cookie(name string) string { cookies := c.Req.Cookies() for _, cookie := range cookies { if cookie.Name == name { return cookie.Value } } return "" }
[ "func", "(", "c", "Context", ")", "Cookie", "(", "name", "string", ")", "string", "{", "cookies", ":=", "c", ".", "Req", ".", "Cookies", "(", ")", "\n", "for", "_", ",", "cookie", ":=", "range", "cookies", "{", "if", "cookie", ".", "Name", "==", ...
// Cookie gets the value of a cookie with name name.
[ "Cookie", "gets", "the", "value", "of", "a", "cookie", "with", "name", "name", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/tplcontext.go#L82-L90
124,908
mholt/caddy
caddyhttp/httpserver/tplcontext.go
Header
func (c Context) Header(name string) string { return c.Req.Header.Get(name) }
go
func (c Context) Header(name string) string { return c.Req.Header.Get(name) }
[ "func", "(", "c", "Context", ")", "Header", "(", "name", "string", ")", "string", "{", "return", "c", ".", "Req", ".", "Header", ".", "Get", "(", "name", ")", "\n", "}" ]
// Header gets the value of a request header with field name.
[ "Header", "gets", "the", "value", "of", "a", "request", "header", "with", "field", "name", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/tplcontext.go#L93-L95
124,909
mholt/caddy
caddyhttp/httpserver/tplcontext.go
Env
func (c Context) Env() map[string]string { osEnv := os.Environ() envVars := make(map[string]string, len(osEnv)) for _, env := range osEnv { data := strings.SplitN(env, "=", 2) if len(data) == 2 && len(data[0]) > 0 { envVars[data[0]] = data[1] } } return envVars }
go
func (c Context) Env() map[string]string { osEnv := os.Environ() envVars := make(map[string]string, len(osEnv)) for _, env := range osEnv { data := strings.SplitN(env, "=", 2) if len(data) == 2 && len(data[0]) > 0 { envVars[data[0]] = data[1] } } return envVars }
[ "func", "(", "c", "Context", ")", "Env", "(", ")", "map", "[", "string", "]", "string", "{", "osEnv", ":=", "os", ".", "Environ", "(", ")", "\n", "envVars", ":=", "make", "(", "map", "[", "string", "]", "string", ",", "len", "(", "osEnv", ")", ...
// Env gets a map of the environment variables.
[ "Env", "gets", "a", "map", "of", "the", "environment", "variables", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/tplcontext.go#L110-L120
124,910
mholt/caddy
caddyhttp/httpserver/tplcontext.go
Host
func (c Context) Host() (string, error) { host, _, err := net.SplitHostPort(c.Req.Host) if err != nil { if !strings.Contains(c.Req.Host, ":") { // common with sites served on the default port 80 return c.Req.Host, nil } return "", err } return host, nil }
go
func (c Context) Host() (string, error) { host, _, err := net.SplitHostPort(c.Req.Host) if err != nil { if !strings.Contains(c.Req.Host, ":") { // common with sites served on the default port 80 return c.Req.Host, nil } return "", err } return host, nil }
[ "func", "(", "c", "Context", ")", "Host", "(", ")", "(", "string", ",", "error", ")", "{", "host", ",", "_", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "c", ".", "Req", ".", "Host", ")", "\n", "if", "err", "!=", "nil", "{", "if", "!"...
// Host returns the hostname portion of the Host header // from the HTTP request.
[ "Host", "returns", "the", "hostname", "portion", "of", "the", "Host", "header", "from", "the", "HTTP", "request", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/tplcontext.go#L163-L173
124,911
mholt/caddy
caddyhttp/httpserver/tplcontext.go
PathMatches
func (c Context) PathMatches(pattern string) bool { return Path(c.Req.URL.Path).Matches(pattern) }
go
func (c Context) PathMatches(pattern string) bool { return Path(c.Req.URL.Path).Matches(pattern) }
[ "func", "(", "c", "Context", ")", "PathMatches", "(", "pattern", "string", ")", "bool", "{", "return", "Path", "(", "c", ".", "Req", ".", "URL", ".", "Path", ")", ".", "Matches", "(", "pattern", ")", "\n", "}" ]
// PathMatches returns true if the path portion of the request // URL matches pattern.
[ "PathMatches", "returns", "true", "if", "the", "path", "portion", "of", "the", "request", "URL", "matches", "pattern", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/tplcontext.go#L195-L197
124,912
mholt/caddy
caddyhttp/httpserver/tplcontext.go
StripHTML
func (c Context) StripHTML(s string) string { var buf bytes.Buffer var inTag, inQuotes bool var tagStart int for i, ch := range s { if inTag { if ch == '>' && !inQuotes { inTag = false } else if ch == '<' && !inQuotes { // false start buf.WriteString(s[tagStart:i]) tagStart = i } else if ...
go
func (c Context) StripHTML(s string) string { var buf bytes.Buffer var inTag, inQuotes bool var tagStart int for i, ch := range s { if inTag { if ch == '>' && !inQuotes { inTag = false } else if ch == '<' && !inQuotes { // false start buf.WriteString(s[tagStart:i]) tagStart = i } else if ...
[ "func", "(", "c", "Context", ")", "StripHTML", "(", "s", "string", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "var", "inTag", ",", "inQuotes", "bool", "\n", "var", "tagStart", "int", "\n", "for", "i", ",", "ch", ":=", "range", ...
// StripHTML returns s without HTML tags. It is fairly naive // but works with most valid HTML inputs.
[ "StripHTML", "returns", "s", "without", "HTML", "tags", ".", "It", "is", "fairly", "naive", "but", "works", "with", "most", "valid", "HTML", "inputs", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/tplcontext.go#L216-L245
124,913
mholt/caddy
caddyhttp/httpserver/tplcontext.go
Replace
func (c Context) Replace(input, find, replacement string) string { return strings.Replace(input, find, replacement, -1) }
go
func (c Context) Replace(input, find, replacement string) string { return strings.Replace(input, find, replacement, -1) }
[ "func", "(", "c", "Context", ")", "Replace", "(", "input", ",", "find", ",", "replacement", "string", ")", "string", "{", "return", "strings", ".", "Replace", "(", "input", ",", "find", ",", "replacement", ",", "-", "1", ")", "\n", "}" ]
// Replace replaces instances of find in input with replacement.
[ "Replace", "replaces", "instances", "of", "find", "in", "input", "with", "replacement", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/tplcontext.go#L268-L270
124,914
mholt/caddy
caddyhttp/httpserver/tplcontext.go
Split
func (c Context) Split(s string, sep string) []string { return strings.Split(s, sep) }
go
func (c Context) Split(s string, sep string) []string { return strings.Split(s, sep) }
[ "func", "(", "c", "Context", ")", "Split", "(", "s", "string", ",", "sep", "string", ")", "[", "]", "string", "{", "return", "strings", ".", "Split", "(", "s", ",", "sep", ")", "\n", "}" ]
// Split is a pass-through to strings.Split. It will split the first argument at each instance of the separator and return a slice of strings.
[ "Split", "is", "a", "pass", "-", "through", "to", "strings", ".", "Split", ".", "It", "will", "split", "the", "first", "argument", "at", "each", "instance", "of", "the", "separator", "and", "return", "a", "slice", "of", "strings", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/tplcontext.go#L334-L336
124,915
mholt/caddy
caddyhttp/httpserver/tplcontext.go
Join
func (c Context) Join(a []string, sep string) string { return strings.Join(a, sep) }
go
func (c Context) Join(a []string, sep string) string { return strings.Join(a, sep) }
[ "func", "(", "c", "Context", ")", "Join", "(", "a", "[", "]", "string", ",", "sep", "string", ")", "string", "{", "return", "strings", ".", "Join", "(", "a", ",", "sep", ")", "\n", "}" ]
// Join is a pass-through to strings.Join. It will join the first argument slice with the separator in the second argument and return the result.
[ "Join", "is", "a", "pass", "-", "through", "to", "strings", ".", "Join", ".", "It", "will", "join", "the", "first", "argument", "slice", "with", "the", "separator", "in", "the", "second", "argument", "and", "return", "the", "result", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/tplcontext.go#L339-L341
124,916
mholt/caddy
caddyhttp/httpserver/tplcontext.go
Map
func (c Context) Map(values ...interface{}) (map[string]interface{}, error) { if len(values)%2 != 0 { return nil, fmt.Errorf("Map expects an even number of arguments") } dict := make(map[string]interface{}, len(values)/2) for i := 0; i < len(values); i += 2 { key, ok := values[i].(string) if !ok { return n...
go
func (c Context) Map(values ...interface{}) (map[string]interface{}, error) { if len(values)%2 != 0 { return nil, fmt.Errorf("Map expects an even number of arguments") } dict := make(map[string]interface{}, len(values)/2) for i := 0; i < len(values); i += 2 { key, ok := values[i].(string) if !ok { return n...
[ "func", "(", "c", "Context", ")", "Map", "(", "values", "...", "interface", "{", "}", ")", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "error", ")", "{", "if", "len", "(", "values", ")", "%", "2", "!=", "0", "{", "return", "nil"...
// Map will convert the arguments into a map. It expects alternating string keys and values. This is useful for building more complicated data structures // if you are using subtemplates or things like that.
[ "Map", "will", "convert", "the", "arguments", "into", "a", "map", ".", "It", "expects", "alternating", "string", "keys", "and", "values", ".", "This", "is", "useful", "for", "building", "more", "complicated", "data", "structures", "if", "you", "are", "using"...
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/tplcontext.go#L350-L363
124,917
mholt/caddy
caddyhttp/httpserver/tplcontext.go
Files
func (c Context) Files(name string) ([]string, error) { dir, err := c.Root.Open(path.Clean(name)) if err != nil { return nil, err } defer dir.Close() stat, err := dir.Stat() if err != nil { return nil, err } if !stat.IsDir() { return nil, fmt.Errorf("%v is not a directory", name) } dirInfo, err := dir...
go
func (c Context) Files(name string) ([]string, error) { dir, err := c.Root.Open(path.Clean(name)) if err != nil { return nil, err } defer dir.Close() stat, err := dir.Stat() if err != nil { return nil, err } if !stat.IsDir() { return nil, fmt.Errorf("%v is not a directory", name) } dirInfo, err := dir...
[ "func", "(", "c", "Context", ")", "Files", "(", "name", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "dir", ",", "err", ":=", "c", ".", "Root", ".", "Open", "(", "path", ".", "Clean", "(", "name", ")", ")", "\n", "if", "err...
// Files reads and returns a slice of names from the given directory // relative to the root of Context c.
[ "Files", "reads", "and", "returns", "a", "slice", "of", "names", "from", "the", "given", "directory", "relative", "to", "the", "root", "of", "Context", "c", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/tplcontext.go#L367-L393
124,918
mholt/caddy
caddyhttp/httpserver/tplcontext.go
IsMITM
func (c Context) IsMITM() bool { if val, ok := c.Req.Context().Value(MitmCtxKey).(bool); ok { return val } return false }
go
func (c Context) IsMITM() bool { if val, ok := c.Req.Context().Value(MitmCtxKey).(bool); ok { return val } return false }
[ "func", "(", "c", "Context", ")", "IsMITM", "(", ")", "bool", "{", "if", "val", ",", "ok", ":=", "c", ".", "Req", ".", "Context", "(", ")", ".", "Value", "(", "MitmCtxKey", ")", ".", "(", "bool", ")", ";", "ok", "{", "return", "val", "\n", "}...
// IsMITM returns true if it seems likely that the TLS connection // is being intercepted.
[ "IsMITM", "returns", "true", "if", "it", "seems", "likely", "that", "the", "TLS", "connection", "is", "being", "intercepted", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/tplcontext.go#L397-L402
124,919
mholt/caddy
caddyhttp/httpserver/tplcontext.go
TLSVersion
func (c Context) TLSVersion() (ret string) { if c.Req.TLS != nil { // Safe to ignore an error ret, _ = caddytls.GetSupportedProtocolName(c.Req.TLS.Version) } return }
go
func (c Context) TLSVersion() (ret string) { if c.Req.TLS != nil { // Safe to ignore an error ret, _ = caddytls.GetSupportedProtocolName(c.Req.TLS.Version) } return }
[ "func", "(", "c", "Context", ")", "TLSVersion", "(", ")", "(", "ret", "string", ")", "{", "if", "c", ".", "Req", ".", "TLS", "!=", "nil", "{", "// Safe to ignore an error", "ret", ",", "_", "=", "caddytls", ".", "GetSupportedProtocolName", "(", "c", "....
// Returns either TLS protocol version if TLS used or empty string otherwise
[ "Returns", "either", "TLS", "protocol", "version", "if", "TLS", "used", "or", "empty", "string", "otherwise" ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/tplcontext.go#L456-L462
124,920
mholt/caddy
caddyhttp/log/setup.go
setup
func setup(c *caddy.Controller) error { rules, err := logParse(c) if err != nil { return err } for _, rule := range rules { for _, entry := range rule.Entries { entry.Log.Attach(c) } } httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { return Logger{Next: next, R...
go
func setup(c *caddy.Controller) error { rules, err := logParse(c) if err != nil { return err } for _, rule := range rules { for _, entry := range rule.Entries { entry.Log.Attach(c) } } httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { return Logger{Next: next, R...
[ "func", "setup", "(", "c", "*", "caddy", ".", "Controller", ")", "error", "{", "rules", ",", "err", ":=", "logParse", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "for", "_", ",", "rule", ":=", "range", ...
// setup sets up the logging middleware.
[ "setup", "sets", "up", "the", "logging", "middleware", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/log/setup.go#L26-L43
124,921
mholt/caddy
caddyhttp/httpserver/plugin.go
shortCaddyfileLoader
func shortCaddyfileLoader(serverType string) (caddy.Input, error) { if flag.NArg() > 0 && serverType == "http" { confBody := fmt.Sprintf("%s:%s\n%s", Host, Port, strings.Join(flag.Args(), "\n")) return caddy.CaddyfileInput{ Contents: []byte(confBody), Filepath: "args", ServerTypeName: serverTy...
go
func shortCaddyfileLoader(serverType string) (caddy.Input, error) { if flag.NArg() > 0 && serverType == "http" { confBody := fmt.Sprintf("%s:%s\n%s", Host, Port, strings.Join(flag.Args(), "\n")) return caddy.CaddyfileInput{ Contents: []byte(confBody), Filepath: "args", ServerTypeName: serverTy...
[ "func", "shortCaddyfileLoader", "(", "serverType", "string", ")", "(", "caddy", ".", "Input", ",", "error", ")", "{", "if", "flag", ".", "NArg", "(", ")", ">", "0", "&&", "serverType", "==", "\"", "\"", "{", "confBody", ":=", "fmt", ".", "Sprintf", "...
// shortCaddyfileLoader loads a Caddyfile if positional arguments are // detected, or, in other words, if un-named arguments are provided to // the program. A "short Caddyfile" is one in which each argument // is a line of the Caddyfile. The default host and port are prepended // according to the Host and Port values.
[ "shortCaddyfileLoader", "loads", "a", "Caddyfile", "if", "positional", "arguments", "are", "detected", "or", "in", "other", "words", "if", "un", "-", "named", "arguments", "are", "provided", "to", "the", "program", ".", "A", "short", "Caddyfile", "is", "one", ...
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/plugin.go#L366-L376
124,922
mholt/caddy
caddyhttp/httpserver/plugin.go
RegisterDevDirective
func RegisterDevDirective(name, before string) { if name == "" { fmt.Println("[FATAL] Cannot register empty directive name") os.Exit(1) } if strings.ToLower(name) != name { fmt.Printf("[FATAL] %s: directive name must be lowercase\n", name) os.Exit(1) } for _, dir := range directives { if dir == name { ...
go
func RegisterDevDirective(name, before string) { if name == "" { fmt.Println("[FATAL] Cannot register empty directive name") os.Exit(1) } if strings.ToLower(name) != name { fmt.Printf("[FATAL] %s: directive name must be lowercase\n", name) os.Exit(1) } for _, dir := range directives { if dir == name { ...
[ "func", "RegisterDevDirective", "(", "name", ",", "before", "string", ")", "{", "if", "name", "==", "\"", "\"", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "os", ".", "Exit", "(", "1", ")", "\n", "}", "\n", "if", "strings", ".", "ToLo...
// RegisterDevDirective splices name into the list of directives // immediately before another directive. This function is ONLY // for plugin development purposes! NEVER use it for a plugin // that you are not currently building. If before is empty, // the directive will be appended to the end of the list. // // It is ...
[ "RegisterDevDirective", "splices", "name", "into", "the", "list", "of", "directives", "immediately", "before", "another", "directive", ".", "This", "function", "is", "ONLY", "for", "plugin", "development", "purposes!", "NEVER", "use", "it", "for", "a", "plugin", ...
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/plugin.go#L571-L609
124,923
mholt/caddy
caddyhttp/browse/browse.go
Breadcrumbs
func (l Listing) Breadcrumbs() []Crumb { var result []Crumb if len(l.Path) == 0 { return result } // skip trailing slash lpath := l.Path if lpath[len(lpath)-1] == '/' { lpath = lpath[:len(lpath)-1] } parts := strings.Split(lpath, "/") for i := range parts { txt := parts[i] if i == 0 && parts[i] == "...
go
func (l Listing) Breadcrumbs() []Crumb { var result []Crumb if len(l.Path) == 0 { return result } // skip trailing slash lpath := l.Path if lpath[len(lpath)-1] == '/' { lpath = lpath[:len(lpath)-1] } parts := strings.Split(lpath, "/") for i := range parts { txt := parts[i] if i == 0 && parts[i] == "...
[ "func", "(", "l", "Listing", ")", "Breadcrumbs", "(", ")", "[", "]", "Crumb", "{", "var", "result", "[", "]", "Crumb", "\n\n", "if", "len", "(", "l", ".", "Path", ")", "==", "0", "{", "return", "result", "\n", "}", "\n\n", "// skip trailing slash", ...
// Breadcrumbs returns l.Path where every element maps // the link to the text to display.
[ "Breadcrumbs", "returns", "l", ".", "Path", "where", "every", "element", "maps", "the", "link", "to", "the", "text", "to", "display", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/browse/browse.go#L102-L125
124,924
mholt/caddy
caddyhttp/browse/browse.go
HumanModTime
func (fi FileInfo) HumanModTime(format string) string { return fi.ModTime.Format(format) }
go
func (fi FileInfo) HumanModTime(format string) string { return fi.ModTime.Format(format) }
[ "func", "(", "fi", "FileInfo", ")", "HumanModTime", "(", "format", "string", ")", "string", "{", "return", "fi", ".", "ModTime", ".", "Format", "(", "format", ")", "\n", "}" ]
// HumanModTime returns the modified time of the file as a human-readable string.
[ "HumanModTime", "returns", "the", "modified", "time", "of", "the", "file", "as", "a", "human", "-", "readable", "string", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/browse/browse.go#L145-L147
124,925
mholt/caddy
caddyhttp/browse/browse.go
isSymlinkTargetDir
func isSymlinkTargetDir(f os.FileInfo, urlPath string, config *Config) bool { if !isSymlink(f) { return false } // a bit strange, but we want Stat thru the jailed filesystem to be safe target, err := config.Fs.Root.Open(path.Join(urlPath, f.Name())) if err != nil { return false } defer target.Close() targe...
go
func isSymlinkTargetDir(f os.FileInfo, urlPath string, config *Config) bool { if !isSymlink(f) { return false } // a bit strange, but we want Stat thru the jailed filesystem to be safe target, err := config.Fs.Root.Open(path.Join(urlPath, f.Name())) if err != nil { return false } defer target.Close() targe...
[ "func", "isSymlinkTargetDir", "(", "f", "os", ".", "FileInfo", ",", "urlPath", "string", ",", "config", "*", "Config", ")", "bool", "{", "if", "!", "isSymlink", "(", "f", ")", "{", "return", "false", "\n", "}", "\n\n", "// a bit strange, but we want Stat thr...
// isSymlinkTargetDir return true if f's symbolic link target // is a directory. Return false if not a symbolic link.
[ "isSymlinkTargetDir", "return", "true", "if", "f", "s", "symbolic", "link", "target", "is", "a", "directory", ".", "Return", "false", "if", "not", "a", "symbolic", "link", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/browse/browse.go#L305-L322
124,926
mholt/caddy
caddyhttp/browse/browse.go
handleSortOrder
func (b Browse) handleSortOrder(w http.ResponseWriter, r *http.Request, scope string) (sort string, order string, limit int, err error) { sort, order, limitQuery := r.URL.Query().Get("sort"), r.URL.Query().Get("order"), r.URL.Query().Get("limit") // If the query 'sort' or 'order' is empty, use defaults or any values...
go
func (b Browse) handleSortOrder(w http.ResponseWriter, r *http.Request, scope string) (sort string, order string, limit int, err error) { sort, order, limitQuery := r.URL.Query().Get("sort"), r.URL.Query().Get("order"), r.URL.Query().Get("limit") // If the query 'sort' or 'order' is empty, use defaults or any values...
[ "func", "(", "b", "Browse", ")", "handleSortOrder", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "scope", "string", ")", "(", "sort", "string", ",", "order", "string", ",", "limit", "int", ",", "err", "error", ...
// handleSortOrder gets and stores for a Listing the 'sort' and 'order', // and reads 'limit' if given. The latter is 0 if not given. // // This sets Cookies.
[ "handleSortOrder", "gets", "and", "stores", "for", "a", "Listing", "the", "sort", "and", "order", "and", "reads", "limit", "if", "given", ".", "The", "latter", "is", "0", "if", "not", "given", ".", "This", "sets", "Cookies", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/browse/browse.go#L419-L451
124,927
mholt/caddy
caddyhttp/browse/browse.go
ServeListing
func (b Browse) ServeListing(w http.ResponseWriter, r *http.Request, requestedFilepath http.File, bc *Config) (int, error) { listing, containsIndex, err := b.loadDirectoryContents(requestedFilepath, r.URL.Path, bc) if err != nil { switch { case os.IsPermission(err): return http.StatusForbidden, err case os.I...
go
func (b Browse) ServeListing(w http.ResponseWriter, r *http.Request, requestedFilepath http.File, bc *Config) (int, error) { listing, containsIndex, err := b.loadDirectoryContents(requestedFilepath, r.URL.Path, bc) if err != nil { switch { case os.IsPermission(err): return http.StatusForbidden, err case os.I...
[ "func", "(", "b", "Browse", ")", "ServeListing", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "requestedFilepath", "http", ".", "File", ",", "bc", "*", "Config", ")", "(", "int", ",", "error", ")", "{", "listin...
// ServeListing returns a formatted view of 'requestedFilepath' contents'.
[ "ServeListing", "returns", "a", "formatted", "view", "of", "requestedFilepath", "contents", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/browse/browse.go#L454-L510
124,928
mholt/caddy
caddyhttp/proxy/body.go
rewind
func (b *bufferedBody) rewind() error { if b == nil { return nil } _, err := b.Seek(0, io.SeekStart) return err }
go
func (b *bufferedBody) rewind() error { if b == nil { return nil } _, err := b.Seek(0, io.SeekStart) return err }
[ "func", "(", "b", "*", "bufferedBody", ")", "rewind", "(", ")", "error", "{", "if", "b", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "_", ",", "err", ":=", "b", ".", "Seek", "(", "0", ",", "io", ".", "SeekStart", ")", "\n", "return", ...
// rewind allows bufferedBody to be read again.
[ "rewind", "allows", "bufferedBody", "to", "be", "read", "again", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/proxy/body.go#L32-L38
124,929
mholt/caddy
upgrade.go
signalSuccessToParent
func signalSuccessToParent() { signalParentOnce.Do(func() { if IsUpgrade() { ppipe := os.NewFile(3, "") // parent is reading from pipe at index 3 _, err := ppipe.Write([]byte("success")) // we must send some bytes to the parent if err != nil { log.Printf("[ERROR] Communicating successful i...
go
func signalSuccessToParent() { signalParentOnce.Do(func() { if IsUpgrade() { ppipe := os.NewFile(3, "") // parent is reading from pipe at index 3 _, err := ppipe.Write([]byte("success")) // we must send some bytes to the parent if err != nil { log.Printf("[ERROR] Communicating successful i...
[ "func", "signalSuccessToParent", "(", ")", "{", "signalParentOnce", ".", "Do", "(", "func", "(", ")", "{", "if", "IsUpgrade", "(", ")", "{", "ppipe", ":=", "os", ".", "NewFile", "(", "3", ",", "\"", "\"", ")", "// parent is reading from pipe at index 3", "...
// signalSuccessToParent tells the parent our status using pipe at index 3. // If this process is not a restart, this function does nothing. // Calling this function once this process has successfully initialized // is vital so that the parent process can unblock and kill itself. // This function is idempotent; it exec...
[ "signalSuccessToParent", "tells", "the", "parent", "our", "status", "using", "pipe", "at", "index", "3", ".", "If", "this", "process", "is", "not", "a", "restart", "this", "function", "does", "nothing", ".", "Calling", "this", "function", "once", "this", "pr...
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/upgrade.go#L195-L206
124,930
mholt/caddy
caddyhttp/limits/setup.go
addPathLimit
func addPathLimit(pathLimit []httpserver.PathLimit, path string, limit int64) []httpserver.PathLimit { // Enforces preceding slash if path[0] != '/' { path = "/" + path } // Use the last value if there are duplicates for i, p := range pathLimit { if p.Path == path { pathLimit[i].Limit = limit return pat...
go
func addPathLimit(pathLimit []httpserver.PathLimit, path string, limit int64) []httpserver.PathLimit { // Enforces preceding slash if path[0] != '/' { path = "/" + path } // Use the last value if there are duplicates for i, p := range pathLimit { if p.Path == path { pathLimit[i].Limit = limit return pat...
[ "func", "addPathLimit", "(", "pathLimit", "[", "]", "httpserver", ".", "PathLimit", ",", "path", "string", ",", "limit", "int64", ")", "[", "]", "httpserver", ".", "PathLimit", "{", "// Enforces preceding slash", "if", "path", "[", "0", "]", "!=", "'/'", "...
// addPathLimit appends the path-to-request body limit mapping to pathLimit // Slashes are checked and added to path if necessary. Duplicates are ignored.
[ "addPathLimit", "appends", "the", "path", "-", "to", "-", "request", "body", "limit", "mapping", "to", "pathLimit", "Slashes", "are", "checked", "and", "added", "to", "path", "if", "necessary", ".", "Duplicates", "are", "ignored", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/limits/setup.go#L186-L201
124,931
mholt/caddy
caddyhttp/limits/setup.go
SortPathLimits
func SortPathLimits(pathLimits []httpserver.PathLimit) { sorter := &pathLimitSorter{ pathLimits: pathLimits, by: LengthDescending, } sort.Sort(sorter) }
go
func SortPathLimits(pathLimits []httpserver.PathLimit) { sorter := &pathLimitSorter{ pathLimits: pathLimits, by: LengthDescending, } sort.Sort(sorter) }
[ "func", "SortPathLimits", "(", "pathLimits", "[", "]", "httpserver", ".", "PathLimit", ")", "{", "sorter", ":=", "&", "pathLimitSorter", "{", "pathLimits", ":", "pathLimits", ",", "by", ":", "LengthDescending", ",", "}", "\n", "sort", ".", "Sort", "(", "so...
// SortPathLimits sort pathLimits by their paths length, longest first
[ "SortPathLimits", "sort", "pathLimits", "by", "their", "paths", "length", "longest", "first" ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/limits/setup.go#L204-L210
124,932
mholt/caddy
caddyhttp/limits/setup.go
LengthDescending
func LengthDescending(p1, p2 *httpserver.PathLimit) bool { return len(p1.Path) > len(p2.Path) }
go
func LengthDescending(p1, p2 *httpserver.PathLimit) bool { return len(p1.Path) > len(p2.Path) }
[ "func", "LengthDescending", "(", "p1", ",", "p2", "*", "httpserver", ".", "PathLimit", ")", "bool", "{", "return", "len", "(", "p1", ".", "Path", ")", ">", "len", "(", "p2", ".", "Path", ")", "\n", "}" ]
// LengthDescending is the comparator for SortPathLimits
[ "LengthDescending", "is", "the", "comparator", "for", "SortPathLimits" ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/limits/setup.go#L231-L233
124,933
mholt/caddy
caddyhttp/push/handler.go
servePreloadLinks
func (h Middleware) servePreloadLinks(pusher http.Pusher, headers http.Header, resources []string) { outer: for _, resource := range resources { for _, resource := range parseLinkHeader(resource) { if _, exists := resource.params["nopush"]; exists { continue } if h.isRemoteResource(resource.uri) { ...
go
func (h Middleware) servePreloadLinks(pusher http.Pusher, headers http.Header, resources []string) { outer: for _, resource := range resources { for _, resource := range parseLinkHeader(resource) { if _, exists := resource.params["nopush"]; exists { continue } if h.isRemoteResource(resource.uri) { ...
[ "func", "(", "h", "Middleware", ")", "servePreloadLinks", "(", "pusher", "http", ".", "Pusher", ",", "headers", "http", ".", "Header", ",", "resources", "[", "]", "string", ")", "{", "outer", ":", "for", "_", ",", "resource", ":=", "range", "resources", ...
// servePreloadLinks parses Link headers from backend and pushes resources found in them. // For accepted header formats check parseLinkHeader function. // // If resource has 'nopush' attribute then it will be omitted.
[ "servePreloadLinks", "parses", "Link", "headers", "from", "backend", "and", "pushes", "resources", "found", "in", "them", ".", "For", "accepted", "header", "formats", "check", "parseLinkHeader", "function", ".", "If", "resource", "has", "nopush", "attribute", "the...
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/push/handler.go#L80-L102
124,934
mholt/caddy
caddyhttp/status/status.go
NewRule
func NewRule(basePath string, status int) *Rule { return &Rule{ Base: basePath, StatusCode: status, RequestMatcher: httpserver.PathMatcher(basePath), } }
go
func NewRule(basePath string, status int) *Rule { return &Rule{ Base: basePath, StatusCode: status, RequestMatcher: httpserver.PathMatcher(basePath), } }
[ "func", "NewRule", "(", "basePath", "string", ",", "status", "int", ")", "*", "Rule", "{", "return", "&", "Rule", "{", "Base", ":", "basePath", ",", "StatusCode", ":", "status", ",", "RequestMatcher", ":", "httpserver", ".", "PathMatcher", "(", "basePath",...
// NewRule creates new Rule.
[ "NewRule", "creates", "new", "Rule", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/status/status.go#L37-L43
124,935
mholt/caddy
caddyhttp/status/status.go
ServeHTTP
func (status Status) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { if cfg := httpserver.ConfigSelector(status.Rules).Select(r); cfg != nil { rule := cfg.(*Rule) if rule.StatusCode < 400 { // There's no ability to return response body -- // write the response status code in header and sign...
go
func (status Status) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { if cfg := httpserver.ConfigSelector(status.Rules).Select(r); cfg != nil { rule := cfg.(*Rule) if rule.StatusCode < 400 { // There's no ability to return response body -- // write the response status code in header and sign...
[ "func", "(", "status", "Status", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "(", "int", ",", "error", ")", "{", "if", "cfg", ":=", "httpserver", ".", "ConfigSelector", "(", "status", ".", "R...
// ServeHTTP implements the httpserver.Handler interface
[ "ServeHTTP", "implements", "the", "httpserver", ".", "Handler", "interface" ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/status/status.go#L57-L73
124,936
mholt/caddy
caddyhttp/gzip/gzip.go
Writer
func (w *gzipResponseWriter) Writer() io.Writer { if w.internalWriter == nil { w.internalWriter = w.newWriter() } return w.internalWriter }
go
func (w *gzipResponseWriter) Writer() io.Writer { if w.internalWriter == nil { w.internalWriter = w.newWriter() } return w.internalWriter }
[ "func", "(", "w", "*", "gzipResponseWriter", ")", "Writer", "(", ")", "io", ".", "Writer", "{", "if", "w", ".", "internalWriter", "==", "nil", "{", "w", ".", "internalWriter", "=", "w", ".", "newWriter", "(", ")", "\n", "}", "\n", "return", "w", "....
//Writer use a lazy way to initialize Writer
[ "Writer", "use", "a", "lazy", "way", "to", "initialize", "Writer" ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/gzip/gzip.go#L155-L160
124,937
mholt/caddy
caddyhttp/httpserver/recorder.go
Write
func (r *ResponseRecorder) Write(buf []byte) (int, error) { n, err := r.ResponseWriterWrapper.Write(buf) if err == nil { r.size += n } return n, err }
go
func (r *ResponseRecorder) Write(buf []byte) (int, error) { n, err := r.ResponseWriterWrapper.Write(buf) if err == nil { r.size += n } return n, err }
[ "func", "(", "r", "*", "ResponseRecorder", ")", "Write", "(", "buf", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "n", ",", "err", ":=", "r", ".", "ResponseWriterWrapper", ".", "Write", "(", "buf", ")", "\n", "if", "err", "==", "nil...
// Write is a wrapper that records the size of the body // that gets written.
[ "Write", "is", "a", "wrapper", "that", "records", "the", "size", "of", "the", "body", "that", "gets", "written", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/recorder.go#L66-L72
124,938
mholt/caddy
caddyhttp/httpserver/recorder.go
WriteHeader
func (rb *ResponseBuffer) WriteHeader(status int) { if rb.wroteHeader { return } rb.wroteHeader = true rb.status = status rb.stream = !rb.shouldBuffer(status, rb.header) if rb.stream { rb.CopyHeader() rb.ResponseWriterWrapper.WriteHeader(status) } }
go
func (rb *ResponseBuffer) WriteHeader(status int) { if rb.wroteHeader { return } rb.wroteHeader = true rb.status = status rb.stream = !rb.shouldBuffer(status, rb.header) if rb.stream { rb.CopyHeader() rb.ResponseWriterWrapper.WriteHeader(status) } }
[ "func", "(", "rb", "*", "ResponseBuffer", ")", "WriteHeader", "(", "status", "int", ")", "{", "if", "rb", ".", "wroteHeader", "{", "return", "\n", "}", "\n", "rb", ".", "wroteHeader", "=", "true", "\n\n", "rb", ".", "status", "=", "status", "\n", "rb...
// WriteHeader calls shouldBuffer to decide whether the // upcoming body should be buffered, and then writes // the header to the response.
[ "WriteHeader", "calls", "shouldBuffer", "to", "decide", "whether", "the", "upcoming", "body", "should", "be", "buffered", "and", "then", "writes", "the", "header", "to", "the", "response", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/recorder.go#L155-L167
124,939
mholt/caddy
caddyhttp/httpserver/recorder.go
Write
func (rb *ResponseBuffer) Write(buf []byte) (int, error) { if !rb.wroteHeader { rb.WriteHeader(http.StatusOK) } if rb.stream { return rb.ResponseWriterWrapper.Write(buf) } return rb.Buffer.Write(buf) }
go
func (rb *ResponseBuffer) Write(buf []byte) (int, error) { if !rb.wroteHeader { rb.WriteHeader(http.StatusOK) } if rb.stream { return rb.ResponseWriterWrapper.Write(buf) } return rb.Buffer.Write(buf) }
[ "func", "(", "rb", "*", "ResponseBuffer", ")", "Write", "(", "buf", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "if", "!", "rb", ".", "wroteHeader", "{", "rb", ".", "WriteHeader", "(", "http", ".", "StatusOK", ")", "\n", "}", "\n\n...
// Write writes buf to rb.Buffer if buffering, otherwise // to the ResponseWriter directly if streaming.
[ "Write", "writes", "buf", "to", "rb", ".", "Buffer", "if", "buffering", "otherwise", "to", "the", "ResponseWriter", "directly", "if", "streaming", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/recorder.go#L171-L180
124,940
mholt/caddy
caddyhttp/httpserver/recorder.go
CopyHeader
func (rb *ResponseBuffer) CopyHeader() { for field, val := range rb.header { rb.ResponseWriterWrapper.Header()[field] = val } }
go
func (rb *ResponseBuffer) CopyHeader() { for field, val := range rb.header { rb.ResponseWriterWrapper.Header()[field] = val } }
[ "func", "(", "rb", "*", "ResponseBuffer", ")", "CopyHeader", "(", ")", "{", "for", "field", ",", "val", ":=", "range", "rb", ".", "header", "{", "rb", ".", "ResponseWriterWrapper", ".", "Header", "(", ")", "[", "field", "]", "=", "val", "\n", "}", ...
// CopyHeader copies the buffered header in rb to the ResponseWriter, // but it does not write the header out.
[ "CopyHeader", "copies", "the", "buffered", "header", "in", "rb", "to", "the", "ResponseWriter", "but", "it", "does", "not", "write", "the", "header", "out", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/recorder.go#L189-L193
124,941
mholt/caddy
caddyhttp/httpserver/recorder.go
StatusCodeWriter
func (rb *ResponseBuffer) StatusCodeWriter(w http.ResponseWriter) http.ResponseWriter { return forcedStatusCodeWriter{w, rb} }
go
func (rb *ResponseBuffer) StatusCodeWriter(w http.ResponseWriter) http.ResponseWriter { return forcedStatusCodeWriter{w, rb} }
[ "func", "(", "rb", "*", "ResponseBuffer", ")", "StatusCodeWriter", "(", "w", "http", ".", "ResponseWriter", ")", "http", ".", "ResponseWriter", "{", "return", "forcedStatusCodeWriter", "{", "w", ",", "rb", "}", "\n", "}" ]
// StatusCodeWriter returns an http.ResponseWriter that always // writes the status code stored in rb from when a response // was buffered to it.
[ "StatusCodeWriter", "returns", "an", "http", ".", "ResponseWriter", "that", "always", "writes", "the", "status", "code", "stored", "in", "rb", "from", "when", "a", "response", "was", "buffered", "to", "it", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/recorder.go#L229-L231
124,942
mholt/caddy
caddyhttp/expvar/setup.go
setup
func setup(c *caddy.Controller) error { resource, err := expVarParse(c) if err != nil { return err } // publish any extra information/metrics we may want to capture publishExtraVars() ev := ExpVar{Resource: resource} httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { ...
go
func setup(c *caddy.Controller) error { resource, err := expVarParse(c) if err != nil { return err } // publish any extra information/metrics we may want to capture publishExtraVars() ev := ExpVar{Resource: resource} httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { ...
[ "func", "setup", "(", "c", "*", "caddy", ".", "Controller", ")", "error", "{", "resource", ",", "err", ":=", "expVarParse", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// publish any extra information/metrics we...
// setup configures a new ExpVar middleware instance.
[ "setup", "configures", "a", "new", "ExpVar", "middleware", "instance", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/expvar/setup.go#L34-L51
124,943
mholt/caddy
caddyhttp/expvar/expvar.go
ServeHTTP
func (e ExpVar) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { if httpserver.Path(r.URL.Path).Matches(string(e.Resource)) { expvarHandler(w, r) return 0, nil } return e.Next.ServeHTTP(w, r) }
go
func (e ExpVar) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { if httpserver.Path(r.URL.Path).Matches(string(e.Resource)) { expvarHandler(w, r) return 0, nil } return e.Next.ServeHTTP(w, r) }
[ "func", "(", "e", "ExpVar", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "(", "int", ",", "error", ")", "{", "if", "httpserver", ".", "Path", "(", "r", ".", "URL", ".", "Path", ")", ".", ...
// ServeHTTP handles requests to expvar's configured entry point with // expvar, or passes all other requests up the chain.
[ "ServeHTTP", "handles", "requests", "to", "expvar", "s", "configured", "entry", "point", "with", "expvar", "or", "passes", "all", "other", "requests", "up", "the", "chain", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/expvar/expvar.go#L33-L39
124,944
mholt/caddy
caddyhttp/expvar/expvar.go
expvarHandler
func expvarHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=utf-8") fmt.Fprintf(w, "{\n") first := true expvar.Do(func(kv expvar.KeyValue) { if !first { fmt.Fprintf(w, ",\n") } first = false fmt.Fprintf(w, "%q: %s", kv.Key, kv.Value) }) fmt.Fpr...
go
func expvarHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=utf-8") fmt.Fprintf(w, "{\n") first := true expvar.Do(func(kv expvar.KeyValue) { if !first { fmt.Fprintf(w, ",\n") } first = false fmt.Fprintf(w, "%q: %s", kv.Key, kv.Value) }) fmt.Fpr...
[ "func", "expvarHandler", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "w", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "fmt", ".", "Fprintf", "(", "w", ",", "\""...
// expvarHandler returns a JSON object will all the published variables. // // This is lifted straight from the expvar package.
[ "expvarHandler", "returns", "a", "JSON", "object", "will", "all", "the", "published", "variables", ".", "This", "is", "lifted", "straight", "from", "the", "expvar", "package", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/expvar/expvar.go#L44-L56
124,945
mholt/caddy
caddyhttp/errors/errors.go
errorPage
func (h ErrorHandler) errorPage(w http.ResponseWriter, r *http.Request, code int) { // See if an error page for this status code was specified if pagePath, ok := h.findErrorPage(code); ok { // Try to open it errorPage, err := os.Open(pagePath) if err != nil { // An additional error handling an error... <inse...
go
func (h ErrorHandler) errorPage(w http.ResponseWriter, r *http.Request, code int) { // See if an error page for this status code was specified if pagePath, ok := h.findErrorPage(code); ok { // Try to open it errorPage, err := os.Open(pagePath) if err != nil { // An additional error handling an error... <inse...
[ "func", "(", "h", "ErrorHandler", ")", "errorPage", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "code", "int", ")", "{", "// See if an error page for this status code was specified", "if", "pagePath", ",", "ok", ":=", "...
// errorPage serves a static error page to w according to the status // code. If there is an error serving the error page, a plaintext error // message is written instead, and the extra error is logged.
[ "errorPage", "serves", "a", "static", "error", "page", "to", "w", "according", "to", "the", "status", "code", ".", "If", "there", "is", "an", "error", "serving", "the", "error", "page", "a", "plaintext", "error", "message", "is", "written", "instead", "and...
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/errors/errors.go#L75-L106
124,946
mholt/caddy
caddyhttp/fastcgi/fastcgi.go
splitPos
func (r Rule) splitPos(path string) int { if httpserver.CaseSensitivePath { return strings.Index(path, r.SplitPath) } return strings.Index(strings.ToLower(path), strings.ToLower(r.SplitPath)) }
go
func (r Rule) splitPos(path string) int { if httpserver.CaseSensitivePath { return strings.Index(path, r.SplitPath) } return strings.Index(strings.ToLower(path), strings.ToLower(r.SplitPath)) }
[ "func", "(", "r", "Rule", ")", "splitPos", "(", "path", "string", ")", "int", "{", "if", "httpserver", ".", "CaseSensitivePath", "{", "return", "strings", ".", "Index", "(", "path", ",", "r", ".", "SplitPath", ")", "\n", "}", "\n", "return", "strings",...
// splitPos returns the index where path should be split // based on rule.SplitPath.
[ "splitPos", "returns", "the", "index", "where", "path", "should", "be", "split", "based", "on", "rule", ".", "SplitPath", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/fastcgi/fastcgi.go#L459-L464
124,947
mholt/caddy
caddyhttp/fastcgi/fastcgi.go
AllowedPath
func (r Rule) AllowedPath(requestPath string) bool { for _, ignoredSubPath := range r.IgnoredSubPaths { if httpserver.Path(path.Clean(requestPath)).Matches(path.Join(r.Path, ignoredSubPath)) { return false } } return true }
go
func (r Rule) AllowedPath(requestPath string) bool { for _, ignoredSubPath := range r.IgnoredSubPaths { if httpserver.Path(path.Clean(requestPath)).Matches(path.Join(r.Path, ignoredSubPath)) { return false } } return true }
[ "func", "(", "r", "Rule", ")", "AllowedPath", "(", "requestPath", "string", ")", "bool", "{", "for", "_", ",", "ignoredSubPath", ":=", "range", "r", ".", "IgnoredSubPaths", "{", "if", "httpserver", ".", "Path", "(", "path", ".", "Clean", "(", "requestPat...
// AllowedPath checks if requestPath is not an ignored path.
[ "AllowedPath", "checks", "if", "requestPath", "is", "not", "an", "ignored", "path", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/fastcgi/fastcgi.go#L467-L474
124,948
mholt/caddy
caddyhttp/internalsrv/setup.go
setup
func setup(c *caddy.Controller) error { paths, err := internalParse(c) if err != nil { return err } // Append Internal paths to Caddy config HiddenFiles to ensure // files do not appear in Browse config := httpserver.GetConfig(c) config.HiddenFiles = append(config.HiddenFiles, paths...) config.AddMiddleware...
go
func setup(c *caddy.Controller) error { paths, err := internalParse(c) if err != nil { return err } // Append Internal paths to Caddy config HiddenFiles to ensure // files do not appear in Browse config := httpserver.GetConfig(c) config.HiddenFiles = append(config.HiddenFiles, paths...) config.AddMiddleware...
[ "func", "setup", "(", "c", "*", "caddy", ".", "Controller", ")", "error", "{", "paths", ",", "err", ":=", "internalParse", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Append Internal paths to Caddy config Hid...
// Internal configures a new Internal middleware instance.
[ "Internal", "configures", "a", "new", "Internal", "middleware", "instance", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/internalsrv/setup.go#L30-L46
124,949
mholt/caddy
caddyhttp/httpserver/path.go
Match
func (p PathMatcher) Match(r *http.Request) bool { return Path(r.URL.Path).Matches(string(p)) }
go
func (p PathMatcher) Match(r *http.Request) bool { return Path(r.URL.Path).Matches(string(p)) }
[ "func", "(", "p", "PathMatcher", ")", "Match", "(", "r", "*", "http", ".", "Request", ")", "bool", "{", "return", "Path", "(", "r", ".", "URL", ".", "Path", ")", ".", "Matches", "(", "string", "(", "p", ")", ")", "\n", "}" ]
// Match satisfies RequestMatcher.
[ "Match", "satisfies", "RequestMatcher", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/path.go#L65-L67
124,950
mholt/caddy
caddyhttp/internalsrv/internal.go
ClearHeader
func (w internalResponseWriter) ClearHeader() { w.Header().Del(redirectHeader) w.Header().Del(contentLengthHeader) w.Header().Del(contentEncodingHeader) }
go
func (w internalResponseWriter) ClearHeader() { w.Header().Del(redirectHeader) w.Header().Del(contentLengthHeader) w.Header().Del(contentEncodingHeader) }
[ "func", "(", "w", "internalResponseWriter", ")", "ClearHeader", "(", ")", "{", "w", ".", "Header", "(", ")", ".", "Del", "(", "redirectHeader", ")", "\n", "w", ".", "Header", "(", ")", ".", "Del", "(", "contentLengthHeader", ")", "\n", "w", ".", "Hea...
// ClearHeader removes script headers that would interfere with follow up // redirect requests.
[ "ClearHeader", "removes", "script", "headers", "that", "would", "interfere", "with", "follow", "up", "redirect", "requests", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/internalsrv/internal.go#L87-L91
124,951
mholt/caddy
caddyhttp/httpserver/roller.go
DefaultLogRoller
func DefaultLogRoller() *LogRoller { return &LogRoller{ MaxSize: defaultRotateSize, MaxAge: defaultRotateAge, MaxBackups: defaultRotateKeep, Compress: false, LocalTime: true, } }
go
func DefaultLogRoller() *LogRoller { return &LogRoller{ MaxSize: defaultRotateSize, MaxAge: defaultRotateAge, MaxBackups: defaultRotateKeep, Compress: false, LocalTime: true, } }
[ "func", "DefaultLogRoller", "(", ")", "*", "LogRoller", "{", "return", "&", "LogRoller", "{", "MaxSize", ":", "defaultRotateSize", ",", "MaxAge", ":", "defaultRotateAge", ",", "MaxBackups", ":", "defaultRotateKeep", ",", "Compress", ":", "false", ",", "LocalTime...
// DefaultLogRoller will roll logs by default.
[ "DefaultLogRoller", "will", "roll", "logs", "by", "default", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/roller.go#L116-L124
124,952
mholt/caddy
caddyhttp/markdown/summary/render.go
List
func (r renderer) List(out *bytes.Buffer, text func() bool, flags int) { // TODO: This is not desired (we'd rather not write lists as part of summary), // but see this issue: https://github.com/russross/blackfriday/issues/189 marker := out.Len() if !text() { out.Truncate(marker) } out.Write([]byte{' '}) }
go
func (r renderer) List(out *bytes.Buffer, text func() bool, flags int) { // TODO: This is not desired (we'd rather not write lists as part of summary), // but see this issue: https://github.com/russross/blackfriday/issues/189 marker := out.Len() if !text() { out.Truncate(marker) } out.Write([]byte{' '}) }
[ "func", "(", "r", "renderer", ")", "List", "(", "out", "*", "bytes", ".", "Buffer", ",", "text", "func", "(", ")", "bool", ",", "flags", "int", ")", "{", "// TODO: This is not desired (we'd rather not write lists as part of summary),", "// but see this issue: https://...
// List is the list tag callback.
[ "List", "is", "the", "list", "tag", "callback", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/markdown/summary/render.go#L50-L58
124,953
mholt/caddy
caddyhttp/markdown/summary/render.go
Paragraph
func (r renderer) Paragraph(out *bytes.Buffer, text func() bool) { marker := out.Len() if !text() { out.Truncate(marker) } out.Write([]byte{' '}) }
go
func (r renderer) Paragraph(out *bytes.Buffer, text func() bool) { marker := out.Len() if !text() { out.Truncate(marker) } out.Write([]byte{' '}) }
[ "func", "(", "r", "renderer", ")", "Paragraph", "(", "out", "*", "bytes", ".", "Buffer", ",", "text", "func", "(", ")", "bool", ")", "{", "marker", ":=", "out", ".", "Len", "(", ")", "\n", "if", "!", "text", "(", ")", "{", "out", ".", "Truncate...
// Paragraph is the paragraph tag callback. This renders simple paragraph text // into plain text, such that summaries can be easily generated.
[ "Paragraph", "is", "the", "paragraph", "tag", "callback", ".", "This", "renders", "simple", "paragraph", "text", "into", "plain", "text", "such", "that", "summaries", "can", "be", "easily", "generated", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/markdown/summary/render.go#L65-L71
124,954
mholt/caddy
caddyhttp/markdown/summary/render.go
CodeSpan
func (r renderer) CodeSpan(out *bytes.Buffer, text []byte) { out.Write([]byte("`")) out.Write(text) out.Write([]byte("`")) }
go
func (r renderer) CodeSpan(out *bytes.Buffer, text []byte) { out.Write([]byte("`")) out.Write(text) out.Write([]byte("`")) }
[ "func", "(", "r", "renderer", ")", "CodeSpan", "(", "out", "*", "bytes", ".", "Buffer", ",", "text", "[", "]", "byte", ")", "{", "out", ".", "Write", "(", "[", "]", "byte", "(", "\"", "\"", ")", ")", "\n", "out", ".", "Write", "(", "text", ")...
// CodeSpan is the code span tag callback. Outputs a simple Markdown version // of the code span.
[ "CodeSpan", "is", "the", "code", "span", "tag", "callback", ".", "Outputs", "a", "simple", "Markdown", "version", "of", "the", "code", "span", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/markdown/summary/render.go#L101-L105
124,955
mholt/caddy
caddyhttp/markdown/summary/render.go
DoubleEmphasis
func (r renderer) DoubleEmphasis(out *bytes.Buffer, text []byte) { out.Write(text) }
go
func (r renderer) DoubleEmphasis(out *bytes.Buffer, text []byte) { out.Write(text) }
[ "func", "(", "r", "renderer", ")", "DoubleEmphasis", "(", "out", "*", "bytes", ".", "Buffer", ",", "text", "[", "]", "byte", ")", "{", "out", ".", "Write", "(", "text", ")", "\n", "}" ]
// DoubleEmphasis is the double emphasis tag callback. Outputs a simple // plain-text version of the input.
[ "DoubleEmphasis", "is", "the", "double", "emphasis", "tag", "callback", ".", "Outputs", "a", "simple", "plain", "-", "text", "version", "of", "the", "input", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/markdown/summary/render.go#L109-L111
124,956
mholt/caddy
caddyhttp/markdown/summary/render.go
Link
func (r renderer) Link(out *bytes.Buffer, link []byte, title []byte, content []byte) { out.Write(content) }
go
func (r renderer) Link(out *bytes.Buffer, link []byte, title []byte, content []byte) { out.Write(content) }
[ "func", "(", "r", "renderer", ")", "Link", "(", "out", "*", "bytes", ".", "Buffer", ",", "link", "[", "]", "byte", ",", "title", "[", "]", "byte", ",", "content", "[", "]", "byte", ")", "{", "out", ".", "Write", "(", "content", ")", "\n", "}" ]
// Link is the link tag callback. Outputs a simple plain-text version // of the input.
[ "Link", "is", "the", "link", "tag", "callback", ".", "Outputs", "a", "simple", "plain", "-", "text", "version", "of", "the", "input", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/markdown/summary/render.go#L127-L129
124,957
mholt/caddy
caddyhttp/markdown/summary/render.go
Entity
func (r renderer) Entity(out *bytes.Buffer, entity []byte) { out.Write(entity) }
go
func (r renderer) Entity(out *bytes.Buffer, entity []byte) { out.Write(entity) }
[ "func", "(", "r", "renderer", ")", "Entity", "(", "out", "*", "bytes", ".", "Buffer", ",", "entity", "[", "]", "byte", ")", "{", "out", ".", "Write", "(", "entity", ")", "\n", "}" ]
// Lowlevel callbacks // Entity callback. Outputs a simple plain-text version of the input.
[ "Lowlevel", "callbacks", "Entity", "callback", ".", "Outputs", "a", "simple", "plain", "-", "text", "version", "of", "the", "input", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/markdown/summary/render.go#L149-L151
124,958
mholt/caddy
onevent/hook/hook.go
Hook
func (cfg *Config) Hook(event caddy.EventName, info interface{}) error { if event != cfg.Event { return nil } nonblock := false if len(cfg.Args) >= 1 && cfg.Args[len(cfg.Args)-1] == "&" { // Run command in background; non-blocking nonblock = true cfg.Args = cfg.Args[:len(cfg.Args)-1] } // Execute comman...
go
func (cfg *Config) Hook(event caddy.EventName, info interface{}) error { if event != cfg.Event { return nil } nonblock := false if len(cfg.Args) >= 1 && cfg.Args[len(cfg.Args)-1] == "&" { // Run command in background; non-blocking nonblock = true cfg.Args = cfg.Args[:len(cfg.Args)-1] } // Execute comman...
[ "func", "(", "cfg", "*", "Config", ")", "Hook", "(", "event", "caddy", ".", "EventName", ",", "info", "interface", "{", "}", ")", "error", "{", "if", "event", "!=", "cfg", ".", "Event", "{", "return", "nil", "\n", "}", "\n\n", "nonblock", ":=", "fa...
// Hook executes a command.
[ "Hook", "executes", "a", "command", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/onevent/hook/hook.go#L13-L41
124,959
mholt/caddy
caddyhttp/rewrite/to.go
To
func To(fs http.FileSystem, r *http.Request, to string, replacer httpserver.Replacer) Result { tos := strings.Fields(to) // try each rewrite paths t := "" query := "" for _, v := range tos { t = replacer.Replace(v) tparts := strings.SplitN(t, "?", 2) t = path.Clean(tparts[0]) if len(tparts) > 1 { quer...
go
func To(fs http.FileSystem, r *http.Request, to string, replacer httpserver.Replacer) Result { tos := strings.Fields(to) // try each rewrite paths t := "" query := "" for _, v := range tos { t = replacer.Replace(v) tparts := strings.SplitN(t, "?", 2) t = path.Clean(tparts[0]) if len(tparts) > 1 { quer...
[ "func", "To", "(", "fs", "http", ".", "FileSystem", ",", "r", "*", "http", ".", "Request", ",", "to", "string", ",", "replacer", "httpserver", ".", "Replacer", ")", "Result", "{", "tos", ":=", "strings", ".", "Fields", "(", "to", ")", "\n\n", "// try...
// To attempts rewrite. It attempts to rewrite to first valid path // or the last path if none of the paths are valid.
[ "To", "attempts", "rewrite", ".", "It", "attempts", "to", "rewrite", "to", "first", "valid", "path", "or", "the", "last", "path", "if", "none", "of", "the", "paths", "are", "valid", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/rewrite/to.go#L29-L76
124,960
mholt/caddy
caddyhttp/httpserver/mitm.go
newTLSListener
func newTLSListener(ln net.Listener, config *tls.Config) *tlsHelloListener { return &tlsHelloListener{ Listener: ln, config: config, helloInfos: make(map[string]rawHelloInfo), } }
go
func newTLSListener(ln net.Listener, config *tls.Config) *tlsHelloListener { return &tlsHelloListener{ Listener: ln, config: config, helloInfos: make(map[string]rawHelloInfo), } }
[ "func", "newTLSListener", "(", "ln", "net", ".", "Listener", ",", "config", "*", "tls", ".", "Config", ")", "*", "tlsHelloListener", "{", "return", "&", "tlsHelloListener", "{", "Listener", ":", "ln", ",", "config", ":", "config", ",", "helloInfos", ":", ...
// newTLSListener returns a new tlsHelloListener that wraps ln.
[ "newTLSListener", "returns", "a", "new", "tlsHelloListener", "that", "wraps", "ln", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/mitm.go#L338-L344
124,961
mholt/caddy
caddyhttp/httpserver/mitm.go
Accept
func (l *tlsHelloListener) Accept() (net.Conn, error) { conn, err := l.Listener.Accept() if err != nil { return nil, err } buf := bufpool.Get().(*bytes.Buffer) buf.Reset() helloConn := &clientHelloConn{Conn: conn, listener: l, buf: buf} return tls.Server(helloConn, l.config), nil }
go
func (l *tlsHelloListener) Accept() (net.Conn, error) { conn, err := l.Listener.Accept() if err != nil { return nil, err } buf := bufpool.Get().(*bytes.Buffer) buf.Reset() helloConn := &clientHelloConn{Conn: conn, listener: l, buf: buf} return tls.Server(helloConn, l.config), nil }
[ "func", "(", "l", "*", "tlsHelloListener", ")", "Accept", "(", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "conn", ",", "err", ":=", "l", ".", "Listener", ".", "Accept", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ...
// Accept waits for and returns the next connection to the listener. // After it accepts the underlying connection, it reads the // ClientHello message and stores the parsed data into a map on l.
[ "Accept", "waits", "for", "and", "returns", "the", "next", "connection", "to", "the", "listener", ".", "After", "it", "accepts", "the", "underlying", "connection", "it", "reads", "the", "ClientHello", "message", "and", "stores", "the", "parsed", "data", "into"...
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/mitm.go#L361-L370
124,962
mholt/caddy
caddyhttp/httpserver/mitm.go
advertisesHeartbeatSupport
func (info rawHelloInfo) advertisesHeartbeatSupport() bool { for _, ext := range info.Extensions { if ext == extensionHeartbeat { return true } } return false }
go
func (info rawHelloInfo) advertisesHeartbeatSupport() bool { for _, ext := range info.Extensions { if ext == extensionHeartbeat { return true } } return false }
[ "func", "(", "info", "rawHelloInfo", ")", "advertisesHeartbeatSupport", "(", ")", "bool", "{", "for", "_", ",", "ext", ":=", "range", "info", ".", "Extensions", "{", "if", "ext", "==", "extensionHeartbeat", "{", "return", "true", "\n", "}", "\n", "}", "\...
// advertisesHeartbeatSupport returns true if info indicates // that the client supports the Heartbeat extension.
[ "advertisesHeartbeatSupport", "returns", "true", "if", "info", "indicates", "that", "the", "client", "supports", "the", "Heartbeat", "extension", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/mitm.go#L383-L390
124,963
mholt/caddy
caddyhttp/httpserver/mitm.go
looksLikeChrome
func (info rawHelloInfo) looksLikeChrome() bool { // "We check for ciphers and extensions that Chrome is known // to not support, but do not check for the inclusion of // specific ciphers or extensions, nor do we validate their // order. When appropriate, we check the presence and order // of elliptic curves, comp...
go
func (info rawHelloInfo) looksLikeChrome() bool { // "We check for ciphers and extensions that Chrome is known // to not support, but do not check for the inclusion of // specific ciphers or extensions, nor do we validate their // order. When appropriate, we check the presence and order // of elliptic curves, comp...
[ "func", "(", "info", "rawHelloInfo", ")", "looksLikeChrome", "(", ")", "bool", "{", "// \"We check for ciphers and extensions that Chrome is known", "// to not support, but do not check for the inclusion of", "// specific ciphers or extensions, nor do we validate their", "// order. When ap...
// looksLikeChrome returns true if info looks like a handshake // from a modern version of Chrome.
[ "looksLikeChrome", "returns", "true", "if", "info", "looks", "like", "a", "handshake", "from", "a", "modern", "version", "of", "Chrome", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/mitm.go#L463-L517
124,964
mholt/caddy
caddyhttp/httpserver/mitm.go
looksLikeEdge
func (info rawHelloInfo) looksLikeEdge() bool { // "SChannel connections can by uniquely identified because SChannel // is the only TLS library we tested that includes the OCSP status // request extension before the supported groups and EC point formats // extensions." (early 2016) // // More specifically, the OC...
go
func (info rawHelloInfo) looksLikeEdge() bool { // "SChannel connections can by uniquely identified because SChannel // is the only TLS library we tested that includes the OCSP status // request extension before the supported groups and EC point formats // extensions." (early 2016) // // More specifically, the OC...
[ "func", "(", "info", "rawHelloInfo", ")", "looksLikeEdge", "(", ")", "bool", "{", "// \"SChannel connections can by uniquely identified because SChannel", "// is the only TLS library we tested that includes the OCSP status", "// request extension before the supported groups and EC point form...
// looksLikeEdge returns true if info looks like a handshake // from a modern version of MS Edge.
[ "looksLikeEdge", "returns", "true", "if", "info", "looks", "like", "a", "handshake", "from", "a", "modern", "version", "of", "MS", "Edge", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/mitm.go#L521-L558
124,965
mholt/caddy
caddyhttp/httpserver/mitm.go
looksLikeSafari
func (info rawHelloInfo) looksLikeSafari() bool { // "One unique aspect of Secure Transport is that it includes // the TLS_EMPTY_RENEGOTIATION_INFO_SCSV (0xff) cipher first, // whereas the other libraries we investigated include the // cipher last. Similar to Microsoft, Apple has changed // TLS behavior in minor O...
go
func (info rawHelloInfo) looksLikeSafari() bool { // "One unique aspect of Secure Transport is that it includes // the TLS_EMPTY_RENEGOTIATION_INFO_SCSV (0xff) cipher first, // whereas the other libraries we investigated include the // cipher last. Similar to Microsoft, Apple has changed // TLS behavior in minor O...
[ "func", "(", "info", "rawHelloInfo", ")", "looksLikeSafari", "(", ")", "bool", "{", "// \"One unique aspect of Secure Transport is that it includes", "// the TLS_EMPTY_RENEGOTIATION_INFO_SCSV (0xff) cipher first,", "// whereas the other libraries we investigated include the", "// cipher la...
// looksLikeSafari returns true if info looks like a handshake // from a modern version of MS Safari.
[ "looksLikeSafari", "returns", "true", "if", "info", "looks", "like", "a", "handshake", "from", "a", "modern", "version", "of", "MS", "Safari", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/mitm.go#L562-L621
124,966
mholt/caddy
caddyhttp/httpserver/mitm.go
assertPresenceAndOrdering
func assertPresenceAndOrdering(requiredItems, candidateList []uint16, requiredIsSubset bool) bool { superset := requiredItems subset := candidateList if requiredIsSubset { superset = candidateList subset = requiredItems } var j int for _, item := range subset { var found bool for j < len(superset) { i...
go
func assertPresenceAndOrdering(requiredItems, candidateList []uint16, requiredIsSubset bool) bool { superset := requiredItems subset := candidateList if requiredIsSubset { superset = candidateList subset = requiredItems } var j int for _, item := range subset { var found bool for j < len(superset) { i...
[ "func", "assertPresenceAndOrdering", "(", "requiredItems", ",", "candidateList", "[", "]", "uint16", ",", "requiredIsSubset", "bool", ")", "bool", "{", "superset", ":=", "requiredItems", "\n", "subset", ":=", "candidateList", "\n", "if", "requiredIsSubset", "{", "...
// assertPresenceAndOrdering will return true if candidateList contains // the items in requiredItems in the same order as requiredItems. // // If requiredIsSubset is true, then all items in requiredItems must be // present in candidateList. If requiredIsSubset is false, then requiredItems // may contain items that are...
[ "assertPresenceAndOrdering", "will", "return", "true", "if", "candidateList", "contains", "the", "items", "in", "requiredItems", "in", "the", "same", "order", "as", "requiredItems", ".", "If", "requiredIsSubset", "is", "true", "then", "all", "items", "in", "requir...
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/mitm.go#L695-L718
124,967
mholt/caddy
caddyhttp/pprof/pprof.go
ServeHTTP
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { if httpserver.Path(r.URL.Path).Matches(BasePath) { h.Mux.ServeHTTP(w, r) return 0, nil } return h.Next.ServeHTTP(w, r) }
go
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { if httpserver.Path(r.URL.Path).Matches(BasePath) { h.Mux.ServeHTTP(w, r) return 0, nil } return h.Next.ServeHTTP(w, r) }
[ "func", "(", "h", "*", "Handler", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "(", "int", ",", "error", ")", "{", "if", "httpserver", ".", "Path", "(", "r", ".", "URL", ".", "Path", ")", ...
// ServeHTTP handles requests to BasePath with pprof, or passes // all other requests up the chain.
[ "ServeHTTP", "handles", "requests", "to", "BasePath", "with", "pprof", "or", "passes", "all", "other", "requests", "up", "the", "chain", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/pprof/pprof.go#L36-L42
124,968
mholt/caddy
caddyhttp/proxy/proxy.go
match
func (p Proxy) match(r *http.Request) Upstream { var u Upstream var longestMatch int for _, upstream := range p.Upstreams { basePath := upstream.From() if !httpserver.Path(r.URL.Path).Matches(basePath) || !upstream.AllowedPath(r.URL.Path) { continue } if len(basePath) > longestMatch { longestMatch = le...
go
func (p Proxy) match(r *http.Request) Upstream { var u Upstream var longestMatch int for _, upstream := range p.Upstreams { basePath := upstream.From() if !httpserver.Path(r.URL.Path).Matches(basePath) || !upstream.AllowedPath(r.URL.Path) { continue } if len(basePath) > longestMatch { longestMatch = le...
[ "func", "(", "p", "Proxy", ")", "match", "(", "r", "*", "http", ".", "Request", ")", "Upstream", "{", "var", "u", "Upstream", "\n", "var", "longestMatch", "int", "\n", "for", "_", ",", "upstream", ":=", "range", "p", ".", "Upstreams", "{", "basePath"...
// match finds the best match for a proxy config based on r.
[ "match", "finds", "the", "best", "match", "for", "a", "proxy", "config", "based", "on", "r", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/proxy/proxy.go#L292-L306
124,969
mholt/caddy
caddyhttp/proxy/proxy.go
createUpstreamRequest
func createUpstreamRequest(rw http.ResponseWriter, r *http.Request) (*http.Request, context.CancelFunc) { // Original incoming server request may be canceled by the // user or by std lib(e.g. too many idle connections). ctx, cancel := context.WithCancel(r.Context()) if cn, ok := rw.(http.CloseNotifier); ok { noti...
go
func createUpstreamRequest(rw http.ResponseWriter, r *http.Request) (*http.Request, context.CancelFunc) { // Original incoming server request may be canceled by the // user or by std lib(e.g. too many idle connections). ctx, cancel := context.WithCancel(r.Context()) if cn, ok := rw.(http.CloseNotifier); ok { noti...
[ "func", "createUpstreamRequest", "(", "rw", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Request", ",", "context", ".", "CancelFunc", ")", "{", "// Original incoming server request may be canceled by the", "// ...
// createUpstreamRequest shallow-copies r into a new request // that can be sent upstream. // // Derived from reverseproxy.go in the standard Go httputil package.
[ "createUpstreamRequest", "shallow", "-", "copies", "r", "into", "a", "new", "request", "that", "can", "be", "sent", "upstream", ".", "Derived", "from", "reverseproxy", ".", "go", "in", "the", "standard", "Go", "httputil", "package", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/proxy/proxy.go#L312-L379
124,970
mholt/caddy
caddyhttp/markdown/metadata/metadata.go
NewMetadata
func NewMetadata(parsedMap map[string]interface{}) Metadata { md := Metadata{ Variables: make(map[string]interface{}), } md.load(parsedMap) return md }
go
func NewMetadata(parsedMap map[string]interface{}) Metadata { md := Metadata{ Variables: make(map[string]interface{}), } md.load(parsedMap) return md }
[ "func", "NewMetadata", "(", "parsedMap", "map", "[", "string", "]", "interface", "{", "}", ")", "Metadata", "{", "md", ":=", "Metadata", "{", "Variables", ":", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", ",", "}", "\n", "md", ...
// NewMetadata returns a new Metadata struct, loaded with the given map
[ "NewMetadata", "returns", "a", "new", "Metadata", "struct", "loaded", "with", "the", "given", "map" ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/markdown/metadata/metadata.go#L48-L55
124,971
mholt/caddy
caddyhttp/markdown/metadata/metadata.go
load
func (m *Metadata) load(parsedMap map[string]interface{}) { // Pull top level things out if title, ok := parsedMap["title"]; ok { m.Title, _ = title.(string) } if template, ok := parsedMap["template"]; ok { m.Template, _ = template.(string) } if date, ok := parsedMap["date"].(string); ok { for _, layout :=...
go
func (m *Metadata) load(parsedMap map[string]interface{}) { // Pull top level things out if title, ok := parsedMap["title"]; ok { m.Title, _ = title.(string) } if template, ok := parsedMap["template"]; ok { m.Template, _ = template.(string) } if date, ok := parsedMap["date"].(string); ok { for _, layout :=...
[ "func", "(", "m", "*", "Metadata", ")", "load", "(", "parsedMap", "map", "[", "string", "]", "interface", "{", "}", ")", "{", "// Pull top level things out", "if", "title", ",", "ok", ":=", "parsedMap", "[", "\"", "\"", "]", ";", "ok", "{", "m", ".",...
// load loads parsed values in parsedMap into Metadata
[ "load", "loads", "parsed", "values", "in", "parsedMap", "into", "Metadata" ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/markdown/metadata/metadata.go#L58-L77
124,972
mholt/caddy
caddyhttp/markdown/metadata/metadata.go
GetParser
func GetParser(buf []byte) Parser { for _, p := range parsers() { b := bytes.NewBuffer(buf) if p.Init(b) { return p } } return nil }
go
func GetParser(buf []byte) Parser { for _, p := range parsers() { b := bytes.NewBuffer(buf) if p.Init(b) { return p } } return nil }
[ "func", "GetParser", "(", "buf", "[", "]", "byte", ")", "Parser", "{", "for", "_", ",", "p", ":=", "range", "parsers", "(", ")", "{", "b", ":=", "bytes", ".", "NewBuffer", "(", "buf", ")", "\n", "if", "p", ".", "Init", "(", "b", ")", "{", "re...
// GetParser returns a parser for the given data
[ "GetParser", "returns", "a", "parser", "for", "the", "given", "data" ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/markdown/metadata/metadata.go#L95-L104
124,973
mholt/caddy
caddyhttp/httpserver/https.go
markQualifiedForAutoHTTPS
func markQualifiedForAutoHTTPS(configs []*SiteConfig) { for _, cfg := range configs { if caddytls.QualifiesForManagedTLS(cfg) && cfg.Addr.Scheme != "http" { cfg.TLS.Managed = true } } }
go
func markQualifiedForAutoHTTPS(configs []*SiteConfig) { for _, cfg := range configs { if caddytls.QualifiesForManagedTLS(cfg) && cfg.Addr.Scheme != "http" { cfg.TLS.Managed = true } } }
[ "func", "markQualifiedForAutoHTTPS", "(", "configs", "[", "]", "*", "SiteConfig", ")", "{", "for", "_", ",", "cfg", ":=", "range", "configs", "{", "if", "caddytls", ".", "QualifiesForManagedTLS", "(", "cfg", ")", "&&", "cfg", ".", "Addr", ".", "Scheme", ...
// markQualifiedForAutoHTTPS scans each config and, if it // qualifies for managed TLS, it sets the Managed field of // the TLS config to true.
[ "markQualifiedForAutoHTTPS", "scans", "each", "config", "and", "if", "it", "qualifies", "for", "managed", "TLS", "it", "sets", "the", "Managed", "field", "of", "the", "TLS", "config", "to", "true", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/https.go#L90-L96
124,974
mholt/caddy
caddyhttp/httpserver/https.go
enableAutoHTTPS
func enableAutoHTTPS(configs []*SiteConfig, loadCertificates bool) error { for _, cfg := range configs { if cfg == nil || cfg.TLS == nil || !cfg.TLS.Managed || cfg.TLS.Manager == nil || cfg.TLS.Manager.OnDemand != nil { continue } cfg.TLS.Enabled = true cfg.Addr.Scheme = "https" if loadCertificates && ...
go
func enableAutoHTTPS(configs []*SiteConfig, loadCertificates bool) error { for _, cfg := range configs { if cfg == nil || cfg.TLS == nil || !cfg.TLS.Managed || cfg.TLS.Manager == nil || cfg.TLS.Manager.OnDemand != nil { continue } cfg.TLS.Enabled = true cfg.Addr.Scheme = "https" if loadCertificates && ...
[ "func", "enableAutoHTTPS", "(", "configs", "[", "]", "*", "SiteConfig", ",", "loadCertificates", "bool", ")", "error", "{", "for", "_", ",", "cfg", ":=", "range", "configs", "{", "if", "cfg", "==", "nil", "||", "cfg", ".", "TLS", "==", "nil", "||", "...
// enableAutoHTTPS configures each config to use TLS according to default settings. // It will only change configs that are marked as managed but not on-demand, and // assumes that certificates and keys are already on disk. If loadCertificates is // true, the certificates will be loaded from disk into the cache for thi...
[ "enableAutoHTTPS", "configures", "each", "config", "to", "use", "TLS", "according", "to", "default", "settings", ".", "It", "will", "only", "change", "configs", "that", "are", "marked", "as", "managed", "but", "not", "on", "-", "demand", "and", "assumes", "t...
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/https.go#L105-L132
124,975
mholt/caddy
caddyhttp/httpserver/https.go
makePlaintextRedirects
func makePlaintextRedirects(allConfigs []*SiteConfig) []*SiteConfig { for i, cfg := range allConfigs { if cfg.TLS.Managed && !hostHasOtherPort(allConfigs, i, HTTPPort) && (cfg.Addr.Port == HTTPSPort || !hostHasOtherPort(allConfigs, i, HTTPSPort)) { allConfigs = append(allConfigs, redirPlaintextHost(cfg)) ...
go
func makePlaintextRedirects(allConfigs []*SiteConfig) []*SiteConfig { for i, cfg := range allConfigs { if cfg.TLS.Managed && !hostHasOtherPort(allConfigs, i, HTTPPort) && (cfg.Addr.Port == HTTPSPort || !hostHasOtherPort(allConfigs, i, HTTPSPort)) { allConfigs = append(allConfigs, redirPlaintextHost(cfg)) ...
[ "func", "makePlaintextRedirects", "(", "allConfigs", "[", "]", "*", "SiteConfig", ")", "[", "]", "*", "SiteConfig", "{", "for", "i", ",", "cfg", ":=", "range", "allConfigs", "{", "if", "cfg", ".", "TLS", ".", "Managed", "&&", "!", "hostHasOtherPort", "("...
// makePlaintextRedirects sets up redirects from port 80 to the relevant HTTPS // hosts. You must pass in all configs, not just configs that qualify, since // we must know whether the same host already exists on port 80, and those would // not be in a list of configs that qualify for automatic HTTPS. This function will...
[ "makePlaintextRedirects", "sets", "up", "redirects", "from", "port", "80", "to", "the", "relevant", "HTTPS", "hosts", ".", "You", "must", "pass", "in", "all", "configs", "not", "just", "configs", "that", "qualify", "since", "we", "must", "know", "whether", "...
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/httpserver/https.go#L140-L149
124,976
mholt/caddy
caddyhttp/proxy/upstream.go
Stop
func (u *staticUpstream) Stop() error { close(u.stop) u.wg.Wait() return nil }
go
func (u *staticUpstream) Stop() error { close(u.stop) u.wg.Wait() return nil }
[ "func", "(", "u", "*", "staticUpstream", ")", "Stop", "(", ")", "error", "{", "close", "(", "u", ".", "stop", ")", "\n", "u", ".", "wg", ".", "Wait", "(", ")", "\n", "return", "nil", "\n", "}" ]
// Stop sends a signal to all goroutines started by this staticUpstream to exit // and waits for them to finish before returning.
[ "Stop", "sends", "a", "signal", "to", "all", "goroutines", "started", "by", "this", "staticUpstream", "to", "exit", "and", "waits", "for", "them", "to", "finish", "before", "returning", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/proxy/upstream.go#L757-L761
124,977
mholt/caddy
caddyhttp/basicauth/basicauth.go
GetHtpasswdMatcher
func GetHtpasswdMatcher(filename, username, siteRoot string) (PasswordMatcher, error) { filename = filepath.Join(siteRoot, filename) htpasswordsMu.Lock() if htpasswords == nil { htpasswords = make(map[string]map[string]PasswordMatcher) } pm := htpasswords[filename] if pm == nil { fh, err := os.Open(filename) ...
go
func GetHtpasswdMatcher(filename, username, siteRoot string) (PasswordMatcher, error) { filename = filepath.Join(siteRoot, filename) htpasswordsMu.Lock() if htpasswords == nil { htpasswords = make(map[string]map[string]PasswordMatcher) } pm := htpasswords[filename] if pm == nil { fh, err := os.Open(filename) ...
[ "func", "GetHtpasswdMatcher", "(", "filename", ",", "username", ",", "siteRoot", "string", ")", "(", "PasswordMatcher", ",", "error", ")", "{", "filename", "=", "filepath", ".", "Join", "(", "siteRoot", ",", "filename", ")", "\n", "htpasswordsMu", ".", "Lock...
// GetHtpasswdMatcher matches password rules.
[ "GetHtpasswdMatcher", "matches", "password", "rules", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/basicauth/basicauth.go#L139-L163
124,978
mholt/caddy
caddyhttp/basicauth/basicauth.go
PlainMatcher
func PlainMatcher(passw string) PasswordMatcher { // compare hashes of equal length instead of actual password // to avoid leaking password length passwHash := sha1.New() if _, err := passwHash.Write([]byte(passw)); err != nil { log.Printf("[ERROR] unable to write password hash: %v", err) } passwSum := passwHas...
go
func PlainMatcher(passw string) PasswordMatcher { // compare hashes of equal length instead of actual password // to avoid leaking password length passwHash := sha1.New() if _, err := passwHash.Write([]byte(passw)); err != nil { log.Printf("[ERROR] unable to write password hash: %v", err) } passwSum := passwHas...
[ "func", "PlainMatcher", "(", "passw", "string", ")", "PasswordMatcher", "{", "// compare hashes of equal length instead of actual password", "// to avoid leaking password length", "passwHash", ":=", "sha1", ".", "New", "(", ")", "\n", "if", "_", ",", "err", ":=", "passw...
// PlainMatcher returns a PasswordMatcher that does a constant-time // byte comparison against the password passw.
[ "PlainMatcher", "returns", "a", "PasswordMatcher", "that", "does", "a", "constant", "-", "time", "byte", "comparison", "against", "the", "password", "passw", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/basicauth/basicauth.go#L193-L209
124,979
mholt/caddy
caddyfile/lexer.go
load
func (l *lexer) load(input io.Reader) error { l.reader = bufio.NewReader(input) l.line = 1 // discard byte order mark, if present firstCh, _, err := l.reader.ReadRune() if err != nil { return err } if firstCh != 0xFEFF { err := l.reader.UnreadRune() if err != nil { return err } } return nil }
go
func (l *lexer) load(input io.Reader) error { l.reader = bufio.NewReader(input) l.line = 1 // discard byte order mark, if present firstCh, _, err := l.reader.ReadRune() if err != nil { return err } if firstCh != 0xFEFF { err := l.reader.UnreadRune() if err != nil { return err } } return nil }
[ "func", "(", "l", "*", "lexer", ")", "load", "(", "input", "io", ".", "Reader", ")", "error", "{", "l", ".", "reader", "=", "bufio", ".", "NewReader", "(", "input", ")", "\n", "l", ".", "line", "=", "1", "\n\n", "// discard byte order mark, if present"...
// load prepares the lexer to scan an input for tokens. // It discards any leading byte order mark.
[ "load", "prepares", "the", "lexer", "to", "scan", "an", "input", "for", "tokens", ".", "It", "discards", "any", "leading", "byte", "order", "mark", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyfile/lexer.go#L44-L61
124,980
mholt/caddy
caddyhttp/websocket/websocket.go
ServeHTTP
func (ws WebSocket) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { for _, sockConfig := range ws.Sockets { if httpserver.Path(r.URL.Path).Matches(sockConfig.Path) { return serveWS(w, r, &sockConfig) } } // Didn't match a websocket path, so pass-through return ws.Next.ServeHTTP(w, r) }
go
func (ws WebSocket) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { for _, sockConfig := range ws.Sockets { if httpserver.Path(r.URL.Path).Matches(sockConfig.Path) { return serveWS(w, r, &sockConfig) } } // Didn't match a websocket path, so pass-through return ws.Next.ServeHTTP(w, r) }
[ "func", "(", "ws", "WebSocket", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "(", "int", ",", "error", ")", "{", "for", "_", ",", "sockConfig", ":=", "range", "ws", ".", "Sockets", "{", "if"...
// ServeHTTP converts the HTTP request to a WebSocket connection and serves it up.
[ "ServeHTTP", "converts", "the", "HTTP", "request", "to", "a", "WebSocket", "connection", "and", "serves", "it", "up", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/websocket/websocket.go#L83-L92
124,981
mholt/caddy
caddyhttp/websocket/websocket.go
pumpStdin
func pumpStdin(conn *websocket.Conn, stdin io.WriteCloser) { // Setup our connection's websocket ping/pong handlers from our const values. defer conn.Close() conn.SetReadLimit(maxMessageSize) if err := conn.SetReadDeadline(time.Now().Add(pongWait)); err != nil { log.Println("[ERROR] failed to set read deadline: "...
go
func pumpStdin(conn *websocket.Conn, stdin io.WriteCloser) { // Setup our connection's websocket ping/pong handlers from our const values. defer conn.Close() conn.SetReadLimit(maxMessageSize) if err := conn.SetReadDeadline(time.Now().Add(pongWait)); err != nil { log.Println("[ERROR] failed to set read deadline: "...
[ "func", "pumpStdin", "(", "conn", "*", "websocket", ".", "Conn", ",", "stdin", "io", ".", "WriteCloser", ")", "{", "// Setup our connection's websocket ping/pong handlers from our const values.", "defer", "conn", ".", "Close", "(", ")", "\n", "conn", ".", "SetReadLi...
// pumpStdin handles reading data from the websocket connection and writing // it to stdin of the process.
[ "pumpStdin", "handles", "reading", "data", "from", "the", "websocket", "connection", "and", "writing", "it", "to", "stdin", "of", "the", "process", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/websocket/websocket.go#L223-L246
124,982
mholt/caddy
caddyhttp/websocket/websocket.go
pumpStdout
func pumpStdout(conn *websocket.Conn, stdout io.Reader, done chan struct{}) { go pinger(conn, done) defer func() { _ = conn.Close() close(done) // make sure to close the pinger when we are done. }() s := bufio.NewScanner(stdout) for s.Scan() { if err := conn.SetWriteDeadline(time.Now().Add(writeWait)); err ...
go
func pumpStdout(conn *websocket.Conn, stdout io.Reader, done chan struct{}) { go pinger(conn, done) defer func() { _ = conn.Close() close(done) // make sure to close the pinger when we are done. }() s := bufio.NewScanner(stdout) for s.Scan() { if err := conn.SetWriteDeadline(time.Now().Add(writeWait)); err ...
[ "func", "pumpStdout", "(", "conn", "*", "websocket", ".", "Conn", ",", "stdout", "io", ".", "Reader", ",", "done", "chan", "struct", "{", "}", ")", "{", "go", "pinger", "(", "conn", ",", "done", ")", "\n", "defer", "func", "(", ")", "{", "_", "="...
// pumpStdout handles reading data from stdout of the process and writing // it to websocket connection.
[ "pumpStdout", "handles", "reading", "data", "from", "stdout", "of", "the", "process", "and", "writing", "it", "to", "websocket", "connection", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/websocket/websocket.go#L250-L272
124,983
mholt/caddy
caddyhttp/websocket/websocket.go
pinger
func pinger(conn *websocket.Conn, done chan struct{}) { ticker := time.NewTicker(pingPeriod) defer ticker.Stop() for { // blocking loop with select to wait for stimulation. select { case <-ticker.C: if err := conn.WriteControl(websocket.PingMessage, []byte{}, time.Now().Add(writeWait)); err != nil { err ...
go
func pinger(conn *websocket.Conn, done chan struct{}) { ticker := time.NewTicker(pingPeriod) defer ticker.Stop() for { // blocking loop with select to wait for stimulation. select { case <-ticker.C: if err := conn.WriteControl(websocket.PingMessage, []byte{}, time.Now().Add(writeWait)); err != nil { err ...
[ "func", "pinger", "(", "conn", "*", "websocket", ".", "Conn", ",", "done", "chan", "struct", "{", "}", ")", "{", "ticker", ":=", "time", ".", "NewTicker", "(", "pingPeriod", ")", "\n", "defer", "ticker", ".", "Stop", "(", ")", "\n\n", "for", "{", "...
// pinger simulates the websocket to keep it alive with ping messages.
[ "pinger", "simulates", "the", "websocket", "to", "keep", "it", "alive", "with", "ping", "messages", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/websocket/websocket.go#L275-L293
124,984
mholt/caddy
caddyhttp/markdown/process.go
Summarize
func (f FileInfo) Summarize(wordcount int) (string, error) { fp, err := f.ctx.Root.Open(f.Name()) if err != nil { return "", err } defer fp.Close() buf, err := ioutil.ReadAll(fp) if err != nil { return "", err } return string(summary.Markdown(buf, wordcount)), nil }
go
func (f FileInfo) Summarize(wordcount int) (string, error) { fp, err := f.ctx.Root.Open(f.Name()) if err != nil { return "", err } defer fp.Close() buf, err := ioutil.ReadAll(fp) if err != nil { return "", err } return string(summary.Markdown(buf, wordcount)), nil }
[ "func", "(", "f", "FileInfo", ")", "Summarize", "(", "wordcount", "int", ")", "(", "string", ",", "error", ")", "{", "fp", ",", "err", ":=", "f", ".", "ctx", ".", "Root", ".", "Open", "(", "f", ".", "Name", "(", ")", ")", "\n", "if", "err", "...
// Summarize returns an abbreviated string representation of the markdown stored in this file. // wordcount is the number of words returned in the summary.
[ "Summarize", "returns", "an", "abbreviated", "string", "representation", "of", "the", "markdown", "stored", "in", "this", "file", ".", "wordcount", "is", "the", "number", "of", "words", "returned", "in", "the", "summary", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/markdown/process.go#L43-L56
124,985
mholt/caddy
caddytls/tls.go
RegisterDNSProvider
func RegisterDNSProvider(name string, provider DNSProviderConstructor) { dnsProviders[name] = provider caddy.RegisterPlugin("tls.dns."+name, caddy.Plugin{}) }
go
func RegisterDNSProvider(name string, provider DNSProviderConstructor) { dnsProviders[name] = provider caddy.RegisterPlugin("tls.dns."+name, caddy.Plugin{}) }
[ "func", "RegisterDNSProvider", "(", "name", "string", ",", "provider", "DNSProviderConstructor", ")", "{", "dnsProviders", "[", "name", "]", "=", "provider", "\n", "caddy", ".", "RegisterPlugin", "(", "\"", "\"", "+", "name", ",", "caddy", ".", "Plugin", "{"...
// RegisterDNSProvider registers provider by name for solving the ACME DNS challenge.
[ "RegisterDNSProvider", "registers", "provider", "by", "name", "for", "solving", "the", "ACME", "DNS", "challenge", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddytls/tls.go#L107-L110
124,986
mholt/caddy
caddytls/tls.go
RegisterClusterPlugin
func RegisterClusterPlugin(name string, provider ClusterPluginConstructor) { clusterProviders[name] = provider caddy.RegisterPlugin("tls.cluster."+name, caddy.Plugin{}) }
go
func RegisterClusterPlugin(name string, provider ClusterPluginConstructor) { clusterProviders[name] = provider caddy.RegisterPlugin("tls.cluster."+name, caddy.Plugin{}) }
[ "func", "RegisterClusterPlugin", "(", "name", "string", ",", "provider", "ClusterPluginConstructor", ")", "{", "clusterProviders", "[", "name", "]", "=", "provider", "\n", "caddy", ".", "RegisterPlugin", "(", "\"", "\"", "+", "name", ",", "caddy", ".", "Plugin...
// RegisterClusterPlugin registers provider by name for facilitating // cluster-wide operations like storage and synchronization.
[ "RegisterClusterPlugin", "registers", "provider", "by", "name", "for", "facilitating", "cluster", "-", "wide", "operations", "like", "storage", "and", "synchronization", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddytls/tls.go#L123-L126
124,987
mholt/caddy
caddyhttp/redirect/setup.go
setup
func setup(c *caddy.Controller) error { rules, err := redirParse(c) if err != nil { return err } httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { return Redirect{Next: next, Rules: rules} }) return nil }
go
func setup(c *caddy.Controller) error { rules, err := redirParse(c) if err != nil { return err } httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { return Redirect{Next: next, Rules: rules} }) return nil }
[ "func", "setup", "(", "c", "*", "caddy", ".", "Controller", ")", "error", "{", "rules", ",", "err", ":=", "redirParse", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "httpserver", ".", "GetConfig", "(", "c"...
// setup configures a new Redirect middleware instance.
[ "setup", "configures", "a", "new", "Redirect", "middleware", "instance", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/redirect/setup.go#L32-L43
124,988
mholt/caddy
caddyhttp/markdown/metadata/metadata_yaml.go
Init
func (y *YAMLParser) Init(b *bytes.Buffer) bool { meta, data := splitBuffer(b, "---") if meta == nil || data == nil { return false } y.markdown = data m := make(map[string]interface{}) if err := yaml.Unmarshal(meta.Bytes(), &m); err != nil { return false } y.metadata = NewMetadata(m) return true }
go
func (y *YAMLParser) Init(b *bytes.Buffer) bool { meta, data := splitBuffer(b, "---") if meta == nil || data == nil { return false } y.markdown = data m := make(map[string]interface{}) if err := yaml.Unmarshal(meta.Bytes(), &m); err != nil { return false } y.metadata = NewMetadata(m) return true }
[ "func", "(", "y", "*", "YAMLParser", ")", "Init", "(", "b", "*", "bytes", ".", "Buffer", ")", "bool", "{", "meta", ",", "data", ":=", "splitBuffer", "(", "b", ",", "\"", "\"", ")", "\n", "if", "meta", "==", "nil", "||", "data", "==", "nil", "{"...
// Init prepares the metadata parser for parsing.
[ "Init", "prepares", "the", "metadata", "parser", "for", "parsing", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/markdown/metadata/metadata_yaml.go#L35-L49
124,989
mholt/caddy
caddyhttp/extensions/setup.go
setup
func setup(c *caddy.Controller) error { cfg := httpserver.GetConfig(c) root := cfg.Root exts, err := extParse(c) if err != nil { return err } httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { return Ext{ Next: next, Extensions: exts, Root: root, ...
go
func setup(c *caddy.Controller) error { cfg := httpserver.GetConfig(c) root := cfg.Root exts, err := extParse(c) if err != nil { return err } httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { return Ext{ Next: next, Extensions: exts, Root: root, ...
[ "func", "setup", "(", "c", "*", "caddy", ".", "Controller", ")", "error", "{", "cfg", ":=", "httpserver", ".", "GetConfig", "(", "c", ")", "\n", "root", ":=", "cfg", ".", "Root", "\n\n", "exts", ",", "err", ":=", "extParse", "(", "c", ")", "\n", ...
// setup configures a new instance of 'extensions' middleware for clean URLs.
[ "setup", "configures", "a", "new", "instance", "of", "extensions", "middleware", "for", "clean", "URLs", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/extensions/setup.go#L30-L48
124,990
mholt/caddy
caddyhttp/extensions/setup.go
extParse
func extParse(c *caddy.Controller) ([]string, error) { var exts []string for c.Next() { // At least one extension is required if !c.NextArg() { return exts, c.ArgErr() } exts = append(exts, c.Val()) // Tack on any other extensions that may have been listed exts = append(exts, c.RemainingArgs()...) }...
go
func extParse(c *caddy.Controller) ([]string, error) { var exts []string for c.Next() { // At least one extension is required if !c.NextArg() { return exts, c.ArgErr() } exts = append(exts, c.Val()) // Tack on any other extensions that may have been listed exts = append(exts, c.RemainingArgs()...) }...
[ "func", "extParse", "(", "c", "*", "caddy", ".", "Controller", ")", "(", "[", "]", "string", ",", "error", ")", "{", "var", "exts", "[", "]", "string", "\n\n", "for", "c", ".", "Next", "(", ")", "{", "// At least one extension is required", "if", "!", ...
// extParse sets up an instance of extension middleware // from a middleware controller and returns a list of extensions.
[ "extParse", "sets", "up", "an", "instance", "of", "extension", "middleware", "from", "a", "middleware", "controller", "and", "returns", "a", "list", "of", "extensions", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyhttp/extensions/setup.go#L52-L67
124,991
mholt/caddy
caddyfile/dispenser.go
NewDispenser
func NewDispenser(filename string, input io.Reader) Dispenser { tokens, _ := allTokens(input) // ignoring error because nothing to do with it return Dispenser{ filename: filename, tokens: tokens, cursor: -1, } }
go
func NewDispenser(filename string, input io.Reader) Dispenser { tokens, _ := allTokens(input) // ignoring error because nothing to do with it return Dispenser{ filename: filename, tokens: tokens, cursor: -1, } }
[ "func", "NewDispenser", "(", "filename", "string", ",", "input", "io", ".", "Reader", ")", "Dispenser", "{", "tokens", ",", "_", ":=", "allTokens", "(", "input", ")", "// ignoring error because nothing to do with it", "\n", "return", "Dispenser", "{", "filename", ...
// NewDispenser returns a Dispenser, ready to use for parsing the given input.
[ "NewDispenser", "returns", "a", "Dispenser", "ready", "to", "use", "for", "parsing", "the", "given", "input", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyfile/dispenser.go#L35-L42
124,992
mholt/caddy
caddyfile/dispenser.go
NewDispenserTokens
func NewDispenserTokens(filename string, tokens []Token) Dispenser { return Dispenser{ filename: filename, tokens: tokens, cursor: -1, } }
go
func NewDispenserTokens(filename string, tokens []Token) Dispenser { return Dispenser{ filename: filename, tokens: tokens, cursor: -1, } }
[ "func", "NewDispenserTokens", "(", "filename", "string", ",", "tokens", "[", "]", "Token", ")", "Dispenser", "{", "return", "Dispenser", "{", "filename", ":", "filename", ",", "tokens", ":", "tokens", ",", "cursor", ":", "-", "1", ",", "}", "\n", "}" ]
// NewDispenserTokens returns a Dispenser filled with the given tokens.
[ "NewDispenserTokens", "returns", "a", "Dispenser", "filled", "with", "the", "given", "tokens", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyfile/dispenser.go#L45-L51
124,993
mholt/caddy
caddyfile/dispenser.go
Next
func (d *Dispenser) Next() bool { if d.cursor < len(d.tokens)-1 { d.cursor++ return true } return false }
go
func (d *Dispenser) Next() bool { if d.cursor < len(d.tokens)-1 { d.cursor++ return true } return false }
[ "func", "(", "d", "*", "Dispenser", ")", "Next", "(", ")", "bool", "{", "if", "d", ".", "cursor", "<", "len", "(", "d", ".", "tokens", ")", "-", "1", "{", "d", ".", "cursor", "++", "\n", "return", "true", "\n", "}", "\n", "return", "false", "...
// Next loads the next token. Returns true if a token // was loaded; false otherwise. If false, all tokens // have been consumed.
[ "Next", "loads", "the", "next", "token", ".", "Returns", "true", "if", "a", "token", "was", "loaded", ";", "false", "otherwise", ".", "If", "false", "all", "tokens", "have", "been", "consumed", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyfile/dispenser.go#L56-L62
124,994
mholt/caddy
caddyfile/dispenser.go
NextBlock
func (d *Dispenser) NextBlock() bool { if d.nesting > 0 { d.Next() if d.Val() == "}" { d.nesting-- return false } return true } if !d.NextArg() { // block must open on same line return false } if d.Val() != "{" { d.cursor-- // roll back if not opening brace return false } d.Next() if d.Val()...
go
func (d *Dispenser) NextBlock() bool { if d.nesting > 0 { d.Next() if d.Val() == "}" { d.nesting-- return false } return true } if !d.NextArg() { // block must open on same line return false } if d.Val() != "{" { d.cursor-- // roll back if not opening brace return false } d.Next() if d.Val()...
[ "func", "(", "d", "*", "Dispenser", ")", "NextBlock", "(", ")", "bool", "{", "if", "d", ".", "nesting", ">", "0", "{", "d", ".", "Next", "(", ")", "\n", "if", "d", ".", "Val", "(", ")", "==", "\"", "\"", "{", "d", ".", "nesting", "--", "\n"...
// NextBlock can be used as the condition of a for loop // to load the next token as long as it opens a block or // is already in a block. It returns true if a token was // loaded, or false when the block's closing curly brace // was loaded and thus the block ended. Nested blocks are // not supported.
[ "NextBlock", "can", "be", "used", "as", "the", "condition", "of", "a", "for", "loop", "to", "load", "the", "next", "token", "as", "long", "as", "it", "opens", "a", "block", "or", "is", "already", "in", "a", "block", ".", "It", "returns", "true", "if"...
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyfile/dispenser.go#L112-L135
124,995
mholt/caddy
caddyfile/dispenser.go
Val
func (d *Dispenser) Val() string { if d.cursor < 0 || d.cursor >= len(d.tokens) { return "" } return d.tokens[d.cursor].Text }
go
func (d *Dispenser) Val() string { if d.cursor < 0 || d.cursor >= len(d.tokens) { return "" } return d.tokens[d.cursor].Text }
[ "func", "(", "d", "*", "Dispenser", ")", "Val", "(", ")", "string", "{", "if", "d", ".", "cursor", "<", "0", "||", "d", ".", "cursor", ">=", "len", "(", "d", ".", "tokens", ")", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "d", ".", ...
// Val gets the text of the current token. If there is no token // loaded, it returns empty string.
[ "Val", "gets", "the", "text", "of", "the", "current", "token", ".", "If", "there", "is", "no", "token", "loaded", "it", "returns", "empty", "string", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyfile/dispenser.go#L139-L144
124,996
mholt/caddy
caddyfile/dispenser.go
Line
func (d *Dispenser) Line() int { if d.cursor < 0 || d.cursor >= len(d.tokens) { return 0 } return d.tokens[d.cursor].Line }
go
func (d *Dispenser) Line() int { if d.cursor < 0 || d.cursor >= len(d.tokens) { return 0 } return d.tokens[d.cursor].Line }
[ "func", "(", "d", "*", "Dispenser", ")", "Line", "(", ")", "int", "{", "if", "d", ".", "cursor", "<", "0", "||", "d", ".", "cursor", ">=", "len", "(", "d", ".", "tokens", ")", "{", "return", "0", "\n", "}", "\n", "return", "d", ".", "tokens",...
// Line gets the line number of the current token. If there is no token // loaded, it returns 0.
[ "Line", "gets", "the", "line", "number", "of", "the", "current", "token", ".", "If", "there", "is", "no", "token", "loaded", "it", "returns", "0", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyfile/dispenser.go#L148-L153
124,997
mholt/caddy
caddyfile/dispenser.go
File
func (d *Dispenser) File() string { if d.cursor < 0 || d.cursor >= len(d.tokens) { return d.filename } if tokenFilename := d.tokens[d.cursor].File; tokenFilename != "" { return tokenFilename } return d.filename }
go
func (d *Dispenser) File() string { if d.cursor < 0 || d.cursor >= len(d.tokens) { return d.filename } if tokenFilename := d.tokens[d.cursor].File; tokenFilename != "" { return tokenFilename } return d.filename }
[ "func", "(", "d", "*", "Dispenser", ")", "File", "(", ")", "string", "{", "if", "d", ".", "cursor", "<", "0", "||", "d", ".", "cursor", ">=", "len", "(", "d", ".", "tokens", ")", "{", "return", "d", ".", "filename", "\n", "}", "\n", "if", "to...
// File gets the filename of the current token. If there is no token loaded, // it returns the filename originally given when parsing started.
[ "File", "gets", "the", "filename", "of", "the", "current", "token", ".", "If", "there", "is", "no", "token", "loaded", "it", "returns", "the", "filename", "originally", "given", "when", "parsing", "started", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyfile/dispenser.go#L157-L165
124,998
mholt/caddy
caddyfile/dispenser.go
ArgErr
func (d *Dispenser) ArgErr() error { if d.Val() == "{" { return d.Err("Unexpected token '{', expecting argument") } return d.Errf("Wrong argument count or unexpected line ending after '%s'", d.Val()) }
go
func (d *Dispenser) ArgErr() error { if d.Val() == "{" { return d.Err("Unexpected token '{', expecting argument") } return d.Errf("Wrong argument count or unexpected line ending after '%s'", d.Val()) }
[ "func", "(", "d", "*", "Dispenser", ")", "ArgErr", "(", ")", "error", "{", "if", "d", ".", "Val", "(", ")", "==", "\"", "\"", "{", "return", "d", ".", "Err", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "d", ".", "Errf", "(", "\"", "\""...
// ArgErr returns an argument error, meaning that another // argument was expected but not found. In other words, // a line break or open curly brace was encountered instead of // an argument.
[ "ArgErr", "returns", "an", "argument", "error", "meaning", "that", "another", "argument", "was", "expected", "but", "not", "found", ".", "In", "other", "words", "a", "line", "break", "or", "open", "curly", "brace", "was", "encountered", "instead", "of", "an"...
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyfile/dispenser.go#L207-L212
124,999
mholt/caddy
caddyfile/dispenser.go
SyntaxErr
func (d *Dispenser) SyntaxErr(expected string) error { msg := fmt.Sprintf("%s:%d - Syntax error: Unexpected token '%s', expecting '%s'", d.File(), d.Line(), d.Val(), expected) return errors.New(msg) }
go
func (d *Dispenser) SyntaxErr(expected string) error { msg := fmt.Sprintf("%s:%d - Syntax error: Unexpected token '%s', expecting '%s'", d.File(), d.Line(), d.Val(), expected) return errors.New(msg) }
[ "func", "(", "d", "*", "Dispenser", ")", "SyntaxErr", "(", "expected", "string", ")", "error", "{", "msg", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "d", ".", "File", "(", ")", ",", "d", ".", "Line", "(", ")", ",", "d", ".", "Val", "...
// SyntaxErr creates a generic syntax error which explains what was // found and what was expected.
[ "SyntaxErr", "creates", "a", "generic", "syntax", "error", "which", "explains", "what", "was", "found", "and", "what", "was", "expected", "." ]
a2ed91bc45c8b3faa1577ed4c18334d38a581ca7
https://github.com/mholt/caddy/blob/a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/caddyfile/dispenser.go#L216-L219