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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
145,700 | celrenheit/lion | router.go | Subrouter | func (r *Router) Subrouter(mws ...Middleware) *Router {
nr := &Router{
parent: r,
hostrm: r.hostrm,
pattern: r.pattern,
middlewares: Middlewares{},
namedMiddlewares: make(map[string]Middlewares),
host: r.host,
pool: newCtxPool(),
routes: ... | go | func (r *Router) Subrouter(mws ...Middleware) *Router {
nr := &Router{
parent: r,
hostrm: r.hostrm,
pattern: r.pattern,
middlewares: Middlewares{},
namedMiddlewares: make(map[string]Middlewares),
host: r.host,
pool: newCtxPool(),
routes: ... | [
"func",
"(",
"r",
"*",
"Router",
")",
"Subrouter",
"(",
"mws",
"...",
"Middleware",
")",
"*",
"Router",
"{",
"nr",
":=",
"&",
"Router",
"{",
"parent",
":",
"r",
",",
"hostrm",
":",
"r",
".",
"hostrm",
",",
"pattern",
":",
"r",
".",
"pattern",
","... | // Subrouter creates a new router based on the parent router.
//
// A subrouter has the same pattern and host as the parent router.
// It has it's own middlewares. | [
"Subrouter",
"creates",
"a",
"new",
"router",
"based",
"on",
"the",
"parent",
"router",
".",
"A",
"subrouter",
"has",
"the",
"same",
"pattern",
"and",
"host",
"as",
"the",
"parent",
"router",
".",
"It",
"has",
"it",
"s",
"own",
"middlewares",
"."
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L73-L88 |
145,701 | celrenheit/lion | router.go | Group | func (r *Router) Group(pattern string, mws ...Middleware) *Router {
p := r.pattern + pattern
if pattern == "/" && r.pattern != "/" && r.pattern != "" {
p = r.pattern
}
validatePattern(p)
nr := r.Subrouter(mws...)
nr.pattern = p
return nr
} | go | func (r *Router) Group(pattern string, mws ...Middleware) *Router {
p := r.pattern + pattern
if pattern == "/" && r.pattern != "/" && r.pattern != "" {
p = r.pattern
}
validatePattern(p)
nr := r.Subrouter(mws...)
nr.pattern = p
return nr
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"Group",
"(",
"pattern",
"string",
",",
"mws",
"...",
"Middleware",
")",
"*",
"Router",
"{",
"p",
":=",
"r",
".",
"pattern",
"+",
"pattern",
"\n",
"if",
"pattern",
"==",
"\"",
"\"",
"&&",
"r",
".",
"pattern",
... | // Group creates a subrouter with parent pattern provided. | [
"Group",
"creates",
"a",
"subrouter",
"with",
"parent",
"pattern",
"provided",
"."
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L91-L101 |
145,702 | celrenheit/lion | router.go | Handle | func (r *Router) Handle(method, pattern string, handler http.Handler) Route {
var p string
if pattern == "/" && r.pattern != "" {
p = r.pattern
} else {
p = r.pattern + pattern
}
built := r.buildMiddlewares(handler)
rm := r.root().hostrm.Register(r.host)
rt := rm.Register(method, p, built)
// If this rou... | go | func (r *Router) Handle(method, pattern string, handler http.Handler) Route {
var p string
if pattern == "/" && r.pattern != "" {
p = r.pattern
} else {
p = r.pattern + pattern
}
built := r.buildMiddlewares(handler)
rm := r.root().hostrm.Register(r.host)
rt := rm.Register(method, p, built)
// If this rou... | [
"func",
"(",
"r",
"*",
"Router",
")",
"Handle",
"(",
"method",
",",
"pattern",
"string",
",",
"handler",
"http",
".",
"Handler",
")",
"Route",
"{",
"var",
"p",
"string",
"\n",
"if",
"pattern",
"==",
"\"",
"\"",
"&&",
"r",
".",
"pattern",
"!=",
"\""... | // Handle is the underling method responsible for registering a handler for a specific method and pattern. | [
"Handle",
"is",
"the",
"underling",
"method",
"responsible",
"for",
"registering",
"a",
"handler",
"for",
"a",
"specific",
"method",
"and",
"pattern",
"."
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L104-L125 |
145,703 | celrenheit/lion | router.go | ServeHTTP | func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
ctx := r.pool.Get().(*ctx)
ctx.Reset()
ctx.parent = req.Context()
ctx.ResponseWriter = w
ctx.req = req
if h := r.root().hostrm.Match(ctx, req); h != nil {
// We set the context only if there is a match
req = setParamContext(req, ctx)
h... | go | func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
ctx := r.pool.Get().(*ctx)
ctx.Reset()
ctx.parent = req.Context()
ctx.ResponseWriter = w
ctx.req = req
if h := r.root().hostrm.Match(ctx, req); h != nil {
// We set the context only if there is a match
req = setParamContext(req, ctx)
h... | [
"func",
"(",
"r",
"*",
"Router",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"ctx",
":=",
"r",
".",
"pool",
".",
"Get",
"(",
")",
".",
"(",
"*",
"ctx",
")",
"\n",
"ctx",
".",
"... | // ServeHTTP finds the handler associated with the request's path.
// If it is not found it calls the NotFound handler | [
"ServeHTTP",
"finds",
"the",
"handler",
"associated",
"with",
"the",
"request",
"s",
"path",
".",
"If",
"it",
"is",
"not",
"found",
"it",
"calls",
"the",
"NotFound",
"handler"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L129-L146 |
145,704 | celrenheit/lion | router.go | Mount | func (r *Router) Mount(pattern string, sub *Router, mws ...Middleware) {
oldp := r.pattern
host := r.host
var p string
if pattern == "/" {
p = r.pattern
} else {
p = r.pattern + pattern
}
r.pattern = p
for _, route := range sub.routes {
r.Host(route.Host())
for _, method := range route.Methods() {
... | go | func (r *Router) Mount(pattern string, sub *Router, mws ...Middleware) {
oldp := r.pattern
host := r.host
var p string
if pattern == "/" {
p = r.pattern
} else {
p = r.pattern + pattern
}
r.pattern = p
for _, route := range sub.routes {
r.Host(route.Host())
for _, method := range route.Methods() {
... | [
"func",
"(",
"r",
"*",
"Router",
")",
"Mount",
"(",
"pattern",
"string",
",",
"sub",
"*",
"Router",
",",
"mws",
"...",
"Middleware",
")",
"{",
"oldp",
":=",
"r",
".",
"pattern",
"\n",
"host",
":=",
"r",
".",
"host",
"\n\n",
"var",
"p",
"string",
... | // Mount mounts a subrouter at the provided pattern | [
"Mount",
"mounts",
"a",
"subrouter",
"at",
"the",
"provided",
"pattern"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L149-L170 |
145,705 | celrenheit/lion | router.go | Connect | func (r *Router) Connect(pattern string, handler http.Handler) Route {
return r.Handle("CONNECT", pattern, handler)
} | go | func (r *Router) Connect(pattern string, handler http.Handler) Route {
return r.Handle("CONNECT", pattern, handler)
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"Connect",
"(",
"pattern",
"string",
",",
"handler",
"http",
".",
"Handler",
")",
"Route",
"{",
"return",
"r",
".",
"Handle",
"(",
"\"",
"\"",
",",
"pattern",
",",
"handler",
")",
"\n",
"}"
] | // Connect registers an http CONNECT method receiver with the provided Handler | [
"Connect",
"registers",
"an",
"http",
"CONNECT",
"method",
"receiver",
"with",
"the",
"provided",
"Handler"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L243-L245 |
145,706 | celrenheit/lion | router.go | GET | func (r *Router) GET(pattern string, handler func(Context)) Route {
return r.Handle("GET", pattern, wrap(handler))
} | go | func (r *Router) GET(pattern string, handler func(Context)) Route {
return r.Handle("GET", pattern, wrap(handler))
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"GET",
"(",
"pattern",
"string",
",",
"handler",
"func",
"(",
"Context",
")",
")",
"Route",
"{",
"return",
"r",
".",
"Handle",
"(",
"\"",
"\"",
",",
"pattern",
",",
"wrap",
"(",
"handler",
")",
")",
"\n",
"}"... | // GET registers an http GET method receiver with the provided contextual Handler | [
"GET",
"registers",
"an",
"http",
"GET",
"method",
"receiver",
"with",
"the",
"provided",
"contextual",
"Handler"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L260-L262 |
145,707 | celrenheit/lion | router.go | GetFunc | func (r *Router) GetFunc(pattern string, fn http.HandlerFunc) Route {
return r.Get(pattern, http.HandlerFunc(fn))
} | go | func (r *Router) GetFunc(pattern string, fn http.HandlerFunc) Route {
return r.Get(pattern, http.HandlerFunc(fn))
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"GetFunc",
"(",
"pattern",
"string",
",",
"fn",
"http",
".",
"HandlerFunc",
")",
"Route",
"{",
"return",
"r",
".",
"Get",
"(",
"pattern",
",",
"http",
".",
"HandlerFunc",
"(",
"fn",
")",
")",
"\n",
"}"
] | // GetFunc wraps a HandlerFunc as a Handler and registers it to the router | [
"GetFunc",
"wraps",
"a",
"HandlerFunc",
"as",
"a",
"Handler",
"and",
"registers",
"it",
"to",
"the",
"router"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L310-L312 |
145,708 | celrenheit/lion | router.go | HeadFunc | func (r *Router) HeadFunc(pattern string, fn http.HandlerFunc) Route {
return r.Head(pattern, http.HandlerFunc(fn))
} | go | func (r *Router) HeadFunc(pattern string, fn http.HandlerFunc) Route {
return r.Head(pattern, http.HandlerFunc(fn))
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"HeadFunc",
"(",
"pattern",
"string",
",",
"fn",
"http",
".",
"HandlerFunc",
")",
"Route",
"{",
"return",
"r",
".",
"Head",
"(",
"pattern",
",",
"http",
".",
"HandlerFunc",
"(",
"fn",
")",
")",
"\n",
"}"
] | // HeadFunc wraps a HandlerFunc as a Handler and registers it to the router | [
"HeadFunc",
"wraps",
"a",
"HandlerFunc",
"as",
"a",
"Handler",
"and",
"registers",
"it",
"to",
"the",
"router"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L315-L317 |
145,709 | celrenheit/lion | router.go | PostFunc | func (r *Router) PostFunc(pattern string, fn http.HandlerFunc) Route {
return r.Post(pattern, http.HandlerFunc(fn))
} | go | func (r *Router) PostFunc(pattern string, fn http.HandlerFunc) Route {
return r.Post(pattern, http.HandlerFunc(fn))
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"PostFunc",
"(",
"pattern",
"string",
",",
"fn",
"http",
".",
"HandlerFunc",
")",
"Route",
"{",
"return",
"r",
".",
"Post",
"(",
"pattern",
",",
"http",
".",
"HandlerFunc",
"(",
"fn",
")",
")",
"\n",
"}"
] | // PostFunc wraps a HandlerFunc as a Handler and registers it to the router | [
"PostFunc",
"wraps",
"a",
"HandlerFunc",
"as",
"a",
"Handler",
"and",
"registers",
"it",
"to",
"the",
"router"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L320-L322 |
145,710 | celrenheit/lion | router.go | PutFunc | func (r *Router) PutFunc(pattern string, fn http.HandlerFunc) Route {
return r.Put(pattern, http.HandlerFunc(fn))
} | go | func (r *Router) PutFunc(pattern string, fn http.HandlerFunc) Route {
return r.Put(pattern, http.HandlerFunc(fn))
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"PutFunc",
"(",
"pattern",
"string",
",",
"fn",
"http",
".",
"HandlerFunc",
")",
"Route",
"{",
"return",
"r",
".",
"Put",
"(",
"pattern",
",",
"http",
".",
"HandlerFunc",
"(",
"fn",
")",
")",
"\n",
"}"
] | // PutFunc wraps a HandlerFunc as a Handler and registers it to the router | [
"PutFunc",
"wraps",
"a",
"HandlerFunc",
"as",
"a",
"Handler",
"and",
"registers",
"it",
"to",
"the",
"router"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L325-L327 |
145,711 | celrenheit/lion | router.go | DeleteFunc | func (r *Router) DeleteFunc(pattern string, fn http.HandlerFunc) Route {
return r.Delete(pattern, http.HandlerFunc(fn))
} | go | func (r *Router) DeleteFunc(pattern string, fn http.HandlerFunc) Route {
return r.Delete(pattern, http.HandlerFunc(fn))
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"DeleteFunc",
"(",
"pattern",
"string",
",",
"fn",
"http",
".",
"HandlerFunc",
")",
"Route",
"{",
"return",
"r",
".",
"Delete",
"(",
"pattern",
",",
"http",
".",
"HandlerFunc",
"(",
"fn",
")",
")",
"\n",
"}"
] | // DeleteFunc wraps a HandlerFunc as a Handler and registers it to the router | [
"DeleteFunc",
"wraps",
"a",
"HandlerFunc",
"as",
"a",
"Handler",
"and",
"registers",
"it",
"to",
"the",
"router"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L330-L332 |
145,712 | celrenheit/lion | router.go | TraceFunc | func (r *Router) TraceFunc(pattern string, fn http.HandlerFunc) Route {
return r.Trace(pattern, http.HandlerFunc(fn))
} | go | func (r *Router) TraceFunc(pattern string, fn http.HandlerFunc) Route {
return r.Trace(pattern, http.HandlerFunc(fn))
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"TraceFunc",
"(",
"pattern",
"string",
",",
"fn",
"http",
".",
"HandlerFunc",
")",
"Route",
"{",
"return",
"r",
".",
"Trace",
"(",
"pattern",
",",
"http",
".",
"HandlerFunc",
"(",
"fn",
")",
")",
"\n",
"}"
] | // TraceFunc wraps a HandlerFunc as a Handler and registers it to the router | [
"TraceFunc",
"wraps",
"a",
"HandlerFunc",
"as",
"a",
"Handler",
"and",
"registers",
"it",
"to",
"the",
"router"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L335-L337 |
145,713 | celrenheit/lion | router.go | OptionsFunc | func (r *Router) OptionsFunc(pattern string, fn http.HandlerFunc) Route {
return r.Options(pattern, http.HandlerFunc(fn))
} | go | func (r *Router) OptionsFunc(pattern string, fn http.HandlerFunc) Route {
return r.Options(pattern, http.HandlerFunc(fn))
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"OptionsFunc",
"(",
"pattern",
"string",
",",
"fn",
"http",
".",
"HandlerFunc",
")",
"Route",
"{",
"return",
"r",
".",
"Options",
"(",
"pattern",
",",
"http",
".",
"HandlerFunc",
"(",
"fn",
")",
")",
"\n",
"}"
] | // OptionsFunc wraps a HandlerFunc as a Handler and registers it to the router | [
"OptionsFunc",
"wraps",
"a",
"HandlerFunc",
"as",
"a",
"Handler",
"and",
"registers",
"it",
"to",
"the",
"router"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L340-L342 |
145,714 | celrenheit/lion | router.go | ConnectFunc | func (r *Router) ConnectFunc(pattern string, fn http.HandlerFunc) Route {
return r.Connect(pattern, http.HandlerFunc(fn))
} | go | func (r *Router) ConnectFunc(pattern string, fn http.HandlerFunc) Route {
return r.Connect(pattern, http.HandlerFunc(fn))
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"ConnectFunc",
"(",
"pattern",
"string",
",",
"fn",
"http",
".",
"HandlerFunc",
")",
"Route",
"{",
"return",
"r",
".",
"Connect",
"(",
"pattern",
",",
"http",
".",
"HandlerFunc",
"(",
"fn",
")",
")",
"\n",
"}"
] | // ConnectFunc wraps a HandlerFunc as a Handler and registers it to the router | [
"ConnectFunc",
"wraps",
"a",
"HandlerFunc",
"as",
"a",
"Handler",
"and",
"registers",
"it",
"to",
"the",
"router"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L345-L347 |
145,715 | celrenheit/lion | router.go | PatchFunc | func (r *Router) PatchFunc(pattern string, fn http.HandlerFunc) Route {
return r.Patch(pattern, http.HandlerFunc(fn))
} | go | func (r *Router) PatchFunc(pattern string, fn http.HandlerFunc) Route {
return r.Patch(pattern, http.HandlerFunc(fn))
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"PatchFunc",
"(",
"pattern",
"string",
",",
"fn",
"http",
".",
"HandlerFunc",
")",
"Route",
"{",
"return",
"r",
".",
"Patch",
"(",
"pattern",
",",
"http",
".",
"HandlerFunc",
"(",
"fn",
")",
")",
"\n",
"}"
] | // PatchFunc wraps a HandlerFunc as a Handler and registers it to the router | [
"PatchFunc",
"wraps",
"a",
"HandlerFunc",
"as",
"a",
"Handler",
"and",
"registers",
"it",
"to",
"the",
"router"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L350-L352 |
145,716 | celrenheit/lion | router.go | Use | func (r *Router) Use(middlewares ...Middleware) {
r.middlewares = append(r.middlewares, middlewares...)
} | go | func (r *Router) Use(middlewares ...Middleware) {
r.middlewares = append(r.middlewares, middlewares...)
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"Use",
"(",
"middlewares",
"...",
"Middleware",
")",
"{",
"r",
".",
"middlewares",
"=",
"append",
"(",
"r",
".",
"middlewares",
",",
"middlewares",
"...",
")",
"\n",
"}"
] | // Use registers middlewares to be used | [
"Use",
"registers",
"middlewares",
"to",
"be",
"used"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L355-L357 |
145,717 | celrenheit/lion | router.go | UseFunc | func (r *Router) UseFunc(middlewareFuncs ...MiddlewareFunc) {
for _, fn := range middlewareFuncs {
r.Use(MiddlewareFunc(fn))
}
} | go | func (r *Router) UseFunc(middlewareFuncs ...MiddlewareFunc) {
for _, fn := range middlewareFuncs {
r.Use(MiddlewareFunc(fn))
}
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"UseFunc",
"(",
"middlewareFuncs",
"...",
"MiddlewareFunc",
")",
"{",
"for",
"_",
",",
"fn",
":=",
"range",
"middlewareFuncs",
"{",
"r",
".",
"Use",
"(",
"MiddlewareFunc",
"(",
"fn",
")",
")",
"\n",
"}",
"\n",
"}... | // UseFunc wraps a MiddlewareFunc as a Middleware and registers it middlewares to be used | [
"UseFunc",
"wraps",
"a",
"MiddlewareFunc",
"as",
"a",
"Middleware",
"and",
"registers",
"it",
"middlewares",
"to",
"be",
"used"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L360-L364 |
145,718 | celrenheit/lion | router.go | HandleFunc | func (r *Router) HandleFunc(method, pattern string, fn http.HandlerFunc) Route {
return r.Handle(method, pattern, http.HandlerFunc(fn))
} | go | func (r *Router) HandleFunc(method, pattern string, fn http.HandlerFunc) Route {
return r.Handle(method, pattern, http.HandlerFunc(fn))
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"HandleFunc",
"(",
"method",
",",
"pattern",
"string",
",",
"fn",
"http",
".",
"HandlerFunc",
")",
"Route",
"{",
"return",
"r",
".",
"Handle",
"(",
"method",
",",
"pattern",
",",
"http",
".",
"HandlerFunc",
"(",
... | // HandleFunc wraps a HandlerFunc and pass it to Handle method | [
"HandleFunc",
"wraps",
"a",
"HandlerFunc",
"and",
"pass",
"it",
"to",
"Handle",
"method"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L430-L432 |
145,719 | celrenheit/lion | router.go | Define | func (r *Router) Define(name string, mws ...Middleware) {
r.namedMiddlewares[name] = append(r.namedMiddlewares[name], mws...)
} | go | func (r *Router) Define(name string, mws ...Middleware) {
r.namedMiddlewares[name] = append(r.namedMiddlewares[name], mws...)
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"Define",
"(",
"name",
"string",
",",
"mws",
"...",
"Middleware",
")",
"{",
"r",
".",
"namedMiddlewares",
"[",
"name",
"]",
"=",
"append",
"(",
"r",
".",
"namedMiddlewares",
"[",
"name",
"]",
",",
"mws",
"...",
... | // Define registers some middleware using a name for reuse later using UseNamed method. | [
"Define",
"registers",
"some",
"middleware",
"using",
"a",
"name",
"for",
"reuse",
"later",
"using",
"UseNamed",
"method",
"."
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L518-L520 |
145,720 | celrenheit/lion | router.go | UseNamed | func (r *Router) UseNamed(name string) {
if r.hasNamed(name) { // Find if it this is registered in the current router
r.Use(r.namedMiddlewares[name]...)
} else if !r.isRoot() { // Otherwise, look for it in parent router.
r.parent.UseNamed(name)
} else { // not found
panic("Unknow named middlewares: " + name)
... | go | func (r *Router) UseNamed(name string) {
if r.hasNamed(name) { // Find if it this is registered in the current router
r.Use(r.namedMiddlewares[name]...)
} else if !r.isRoot() { // Otherwise, look for it in parent router.
r.parent.UseNamed(name)
} else { // not found
panic("Unknow named middlewares: " + name)
... | [
"func",
"(",
"r",
"*",
"Router",
")",
"UseNamed",
"(",
"name",
"string",
")",
"{",
"if",
"r",
".",
"hasNamed",
"(",
"name",
")",
"{",
"// Find if it this is registered in the current router",
"r",
".",
"Use",
"(",
"r",
".",
"namedMiddlewares",
"[",
"name",
... | // UseNamed adds a middleware already defined using Define method.
// If it cannot find it in the current router, it will look for it in the parent router. | [
"UseNamed",
"adds",
"a",
"middleware",
"already",
"defined",
"using",
"Define",
"method",
".",
"If",
"it",
"cannot",
"find",
"it",
"in",
"the",
"current",
"router",
"it",
"will",
"look",
"for",
"it",
"in",
"the",
"parent",
"router",
"."
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L531-L539 |
145,721 | celrenheit/lion | router.go | Routes | func (r *Router) Routes() Routes {
routes := make(Routes, len(r.routes))
for i := 0; i < len(r.routes); i++ {
routes[i] = r.routes[i]
}
for _, sr := range r.subrouters {
routes = append(routes, sr.Routes()...)
}
return routes
} | go | func (r *Router) Routes() Routes {
routes := make(Routes, len(r.routes))
for i := 0; i < len(r.routes); i++ {
routes[i] = r.routes[i]
}
for _, sr := range r.subrouters {
routes = append(routes, sr.Routes()...)
}
return routes
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"Routes",
"(",
")",
"Routes",
"{",
"routes",
":=",
"make",
"(",
"Routes",
",",
"len",
"(",
"r",
".",
"routes",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"r",
".",
"routes",
")",
... | // Routes returns the Routes associated with the current Router instance. | [
"Routes",
"returns",
"the",
"Routes",
"associated",
"with",
"the",
"current",
"Router",
"instance",
"."
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L563-L574 |
145,722 | celrenheit/lion | router.go | WithLogger | func WithLogger(logger *log.Logger) RouterOption {
return func(router *Router) {
router.logger = logger
}
} | go | func WithLogger(logger *log.Logger) RouterOption {
return func(router *Router) {
router.logger = logger
}
} | [
"func",
"WithLogger",
"(",
"logger",
"*",
"log",
".",
"Logger",
")",
"RouterOption",
"{",
"return",
"func",
"(",
"router",
"*",
"Router",
")",
"{",
"router",
".",
"logger",
"=",
"logger",
"\n",
"}",
"\n",
"}"
] | // WithLogger allows to customize the underlying logger | [
"WithLogger",
"allows",
"to",
"customize",
"the",
"underlying",
"logger"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L580-L584 |
145,723 | celrenheit/lion | router.go | WithNotFoundHandler | func WithNotFoundHandler(h http.Handler) RouterOption {
return func(router *Router) {
router.notFoundHandler = h
}
} | go | func WithNotFoundHandler(h http.Handler) RouterOption {
return func(router *Router) {
router.notFoundHandler = h
}
} | [
"func",
"WithNotFoundHandler",
"(",
"h",
"http",
".",
"Handler",
")",
"RouterOption",
"{",
"return",
"func",
"(",
"router",
"*",
"Router",
")",
"{",
"router",
".",
"notFoundHandler",
"=",
"h",
"\n",
"}",
"\n",
"}"
] | // WithNotFoundHandler override the default not found handler | [
"WithNotFoundHandler",
"override",
"the",
"default",
"not",
"found",
"handler"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L595-L599 |
145,724 | celrenheit/lion | router.go | Configure | func (r *Router) Configure(opts ...RouterOption) {
for _, o := range opts {
o(r)
}
} | go | func (r *Router) Configure(opts ...RouterOption) {
for _, o := range opts {
o(r)
}
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"Configure",
"(",
"opts",
"...",
"RouterOption",
")",
"{",
"for",
"_",
",",
"o",
":=",
"range",
"opts",
"{",
"o",
"(",
"r",
")",
"\n",
"}",
"\n",
"}"
] | // Configure allows you to customize a Router using RouterOption | [
"Configure",
"allows",
"you",
"to",
"customize",
"a",
"Router",
"using",
"RouterOption"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L602-L606 |
145,725 | celrenheit/lion | middleware/static.go | ServeNext | func (s *Static) ServeNext(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" && r.Method != "HEAD" {
next.ServeHTTP(w, r)
return
}
file := r.URL.Path
// if we have a prefix, filter requests by stripping the prefix
if s.Prefix... | go | func (s *Static) ServeNext(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" && r.Method != "HEAD" {
next.ServeHTTP(w, r)
return
}
file := r.URL.Path
// if we have a prefix, filter requests by stripping the prefix
if s.Prefix... | [
"func",
"(",
"s",
"*",
"Static",
")",
"ServeNext",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request... | // ServeNext tries to find a file in the directory | [
"ServeNext",
"tries",
"to",
"find",
"a",
"file",
"in",
"the",
"directory"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/middleware/static.go#L32-L92 |
145,726 | celrenheit/lion | route.go | String | func (rs Routes) String() string {
sa := make([]string, 0, len(rs))
for _, r := range rs {
sa = append(sa, r.Pattern())
}
return strings.Join(sa, ", ")
} | go | func (rs Routes) String() string {
sa := make([]string, 0, len(rs))
for _, r := range rs {
sa = append(sa, r.Pattern())
}
return strings.Join(sa, ", ")
} | [
"func",
"(",
"rs",
"Routes",
")",
"String",
"(",
")",
"string",
"{",
"sa",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"rs",
")",
")",
"\n",
"for",
"_",
",",
"r",
":=",
"range",
"rs",
"{",
"sa",
"=",
"append",
"(",
"sa... | // String returns a string representation of a list of routes. | [
"String",
"returns",
"a",
"string",
"representation",
"of",
"a",
"list",
"of",
"routes",
"."
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/route.go#L21-L27 |
145,727 | celrenheit/lion | route.go | ByName | func (rs Routes) ByName(name string) Route {
// Since all routes have their name empty by default,
// we cannot return the first route with an empty name
if name == "" {
return nil
}
for _, route := range rs {
if route.Name() == name {
return route
}
}
return nil
} | go | func (rs Routes) ByName(name string) Route {
// Since all routes have their name empty by default,
// we cannot return the first route with an empty name
if name == "" {
return nil
}
for _, route := range rs {
if route.Name() == name {
return route
}
}
return nil
} | [
"func",
"(",
"rs",
"Routes",
")",
"ByName",
"(",
"name",
"string",
")",
"Route",
"{",
"// Since all routes have their name empty by default,",
"// we cannot return the first route with an empty name",
"if",
"name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\... | // ByName returns the route corresponding to the name given.
// It returns nil otherwise. | [
"ByName",
"returns",
"the",
"route",
"corresponding",
"to",
"the",
"name",
"given",
".",
"It",
"returns",
"nil",
"otherwise",
"."
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/route.go#L31-L44 |
145,728 | celrenheit/lion | route.go | ByPattern | func (rs Routes) ByPattern(pattern string) Route {
if pattern == "" {
return nil
}
for _, route := range rs {
if route.Pattern() == pattern {
return route
}
}
return nil
} | go | func (rs Routes) ByPattern(pattern string) Route {
if pattern == "" {
return nil
}
for _, route := range rs {
if route.Pattern() == pattern {
return route
}
}
return nil
} | [
"func",
"(",
"rs",
"Routes",
")",
"ByPattern",
"(",
"pattern",
"string",
")",
"Route",
"{",
"if",
"pattern",
"==",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"for",
"_",
",",
"route",
":=",
"range",
"rs",
"{",
"if",
"route",
".",
"Pattern",... | // ByPattern returns the route corresponding to the pattern given.
// It returns nil otherwise. | [
"ByPattern",
"returns",
"the",
"route",
"corresponding",
"to",
"the",
"pattern",
"given",
".",
"It",
"returns",
"nil",
"otherwise",
"."
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/route.go#L48-L59 |
145,729 | anacrolix/tagflag | misc.go | foreachStructField | func foreachStructField(_struct reflect.Value, f func(fv reflect.Value, sf reflect.StructField) (stop bool)) {
t := _struct.Type()
for i := range iter.N(t.NumField()) {
sf := t.Field(i)
fv := _struct.Field(i)
if f(fv, sf) {
break
}
}
} | go | func foreachStructField(_struct reflect.Value, f func(fv reflect.Value, sf reflect.StructField) (stop bool)) {
t := _struct.Type()
for i := range iter.N(t.NumField()) {
sf := t.Field(i)
fv := _struct.Field(i)
if f(fv, sf) {
break
}
}
} | [
"func",
"foreachStructField",
"(",
"_struct",
"reflect",
".",
"Value",
",",
"f",
"func",
"(",
"fv",
"reflect",
".",
"Value",
",",
"sf",
"reflect",
".",
"StructField",
")",
"(",
"stop",
"bool",
")",
")",
"{",
"t",
":=",
"_struct",
".",
"Type",
"(",
")... | // Walks the fields of the given struct, calling the function with the value
// and StructField for each field. Returning true from the function will halt
// traversal. | [
"Walks",
"the",
"fields",
"of",
"the",
"given",
"struct",
"calling",
"the",
"function",
"with",
"the",
"value",
"and",
"StructField",
"for",
"each",
"field",
".",
"Returning",
"true",
"from",
"the",
"function",
"will",
"halt",
"traversal",
"."
] | 083db3f74197b635e96df78bfc3e2c140b557d82 | https://github.com/anacrolix/tagflag/blob/083db3f74197b635e96df78bfc3e2c140b557d82/misc.go#L16-L25 |
145,730 | anacrolix/tagflag | misc.go | valueMarshaler | func valueMarshaler(t reflect.Type) marshaler {
if zm, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(Marshaler); ok {
return dynamicMarshaler{
marshal: func(v reflect.Value, s string) error {
return v.Addr().Interface().(Marshaler).Marshal(s)
},
explicitValueRequired: zm.RequiresExplicitValue(),
}... | go | func valueMarshaler(t reflect.Type) marshaler {
if zm, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(Marshaler); ok {
return dynamicMarshaler{
marshal: func(v reflect.Value, s string) error {
return v.Addr().Interface().(Marshaler).Marshal(s)
},
explicitValueRequired: zm.RequiresExplicitValue(),
}... | [
"func",
"valueMarshaler",
"(",
"t",
"reflect",
".",
"Type",
")",
"marshaler",
"{",
"if",
"zm",
",",
"ok",
":=",
"reflect",
".",
"Zero",
"(",
"reflect",
".",
"PtrTo",
"(",
"t",
")",
")",
".",
"Interface",
"(",
")",
".",
"(",
"Marshaler",
")",
";",
... | // Returns a marshaler for the given value, or nil if there isn't one. | [
"Returns",
"a",
"marshaler",
"for",
"the",
"given",
"value",
"or",
"nil",
"if",
"there",
"isn",
"t",
"one",
"."
] | 083db3f74197b635e96df78bfc3e2c140b557d82 | https://github.com/anacrolix/tagflag/blob/083db3f74197b635e96df78bfc3e2c140b557d82/misc.go#L32-L68 |
145,731 | anacrolix/tagflag | misc.go | fieldFlagName | func fieldFlagName(fieldName string) flagNameComponent {
return flagNameComponent(func() (ret []rune) {
fieldNameRunes := []rune(fieldName)
for i, r := range fieldNameRunes {
prevUpper := func() bool { return unicode.IsUpper(fieldNameRunes[i-1]) }
nextUpper := func() bool { return unicode.IsUpper(fieldNameRu... | go | func fieldFlagName(fieldName string) flagNameComponent {
return flagNameComponent(func() (ret []rune) {
fieldNameRunes := []rune(fieldName)
for i, r := range fieldNameRunes {
prevUpper := func() bool { return unicode.IsUpper(fieldNameRunes[i-1]) }
nextUpper := func() bool { return unicode.IsUpper(fieldNameRu... | [
"func",
"fieldFlagName",
"(",
"fieldName",
"string",
")",
"flagNameComponent",
"{",
"return",
"flagNameComponent",
"(",
"func",
"(",
")",
"(",
"ret",
"[",
"]",
"rune",
")",
"{",
"fieldNameRunes",
":=",
"[",
"]",
"rune",
"(",
"fieldName",
")",
"\n",
"for",
... | // Turn a struct field name into a flag name. In particular this lower cases
// leading acronyms, and the first capital letter. | [
"Turn",
"a",
"struct",
"field",
"name",
"into",
"a",
"flag",
"name",
".",
"In",
"particular",
"this",
"lower",
"cases",
"leading",
"acronyms",
"and",
"the",
"first",
"capital",
"letter",
"."
] | 083db3f74197b635e96df78bfc3e2c140b557d82 | https://github.com/anacrolix/tagflag/blob/083db3f74197b635e96df78bfc3e2c140b557d82/misc.go#L72-L85 |
145,732 | anacrolix/tagflag | tagflag.go | ParseErr | func ParseErr(cmd interface{}, args []string, opts ...parseOpt) (err error) {
p, err := newParser(cmd, opts...)
if err != nil {
return
}
return p.parse(args)
} | go | func ParseErr(cmd interface{}, args []string, opts ...parseOpt) (err error) {
p, err := newParser(cmd, opts...)
if err != nil {
return
}
return p.parse(args)
} | [
"func",
"ParseErr",
"(",
"cmd",
"interface",
"{",
"}",
",",
"args",
"[",
"]",
"string",
",",
"opts",
"...",
"parseOpt",
")",
"(",
"err",
"error",
")",
"{",
"p",
",",
"err",
":=",
"newParser",
"(",
"cmd",
",",
"opts",
"...",
")",
"\n",
"if",
"err"... | // Parses given arguments, returning any error. | [
"Parses",
"given",
"arguments",
"returning",
"any",
"error",
"."
] | 083db3f74197b635e96df78bfc3e2c140b557d82 | https://github.com/anacrolix/tagflag/blob/083db3f74197b635e96df78bfc3e2c140b557d82/tagflag.go#L18-L24 |
145,733 | anacrolix/tagflag | tagflag.go | Parse | func Parse(cmd interface{}, opts ...parseOpt) {
opts = append([]parseOpt{Program(filepath.Base(os.Args[0]))}, opts...)
ParseArgs(cmd, os.Args[1:], opts...)
} | go | func Parse(cmd interface{}, opts ...parseOpt) {
opts = append([]parseOpt{Program(filepath.Base(os.Args[0]))}, opts...)
ParseArgs(cmd, os.Args[1:], opts...)
} | [
"func",
"Parse",
"(",
"cmd",
"interface",
"{",
"}",
",",
"opts",
"...",
"parseOpt",
")",
"{",
"opts",
"=",
"append",
"(",
"[",
"]",
"parseOpt",
"{",
"Program",
"(",
"filepath",
".",
"Base",
"(",
"os",
".",
"Args",
"[",
"0",
"]",
")",
")",
"}",
... | // Parses the command-line arguments, exiting the process appropriately on
// errors or if usage is printed. | [
"Parses",
"the",
"command",
"-",
"line",
"arguments",
"exiting",
"the",
"process",
"appropriately",
"on",
"errors",
"or",
"if",
"usage",
"is",
"printed",
"."
] | 083db3f74197b635e96df78bfc3e2c140b557d82 | https://github.com/anacrolix/tagflag/blob/083db3f74197b635e96df78bfc3e2c140b557d82/tagflag.go#L28-L31 |
145,734 | anacrolix/tagflag | parser.go | parseStruct | func (p *parser) parseStruct(st reflect.Value, path []flagNameComponent) (err error) {
posStarted := false
foreachStructField(st, func(f reflect.Value, sf reflect.StructField) (stop bool) {
if !posStarted && f.Type() == reflect.TypeOf(StartPos{}) {
posStarted = true
return false
}
if f.Type() == reflect.T... | go | func (p *parser) parseStruct(st reflect.Value, path []flagNameComponent) (err error) {
posStarted := false
foreachStructField(st, func(f reflect.Value, sf reflect.StructField) (stop bool) {
if !posStarted && f.Type() == reflect.TypeOf(StartPos{}) {
posStarted = true
return false
}
if f.Type() == reflect.T... | [
"func",
"(",
"p",
"*",
"parser",
")",
"parseStruct",
"(",
"st",
"reflect",
".",
"Value",
",",
"path",
"[",
"]",
"flagNameComponent",
")",
"(",
"err",
"error",
")",
"{",
"posStarted",
":=",
"false",
"\n",
"foreachStructField",
"(",
"st",
",",
"func",
"(... | // Positional arguments are marked per struct. | [
"Positional",
"arguments",
"are",
"marked",
"per",
"struct",
"."
] | 083db3f74197b635e96df78bfc3e2c140b557d82 | https://github.com/anacrolix/tagflag/blob/083db3f74197b635e96df78bfc3e2c140b557d82/parser.go#L95-L136 |
145,735 | szferi/gomdb | val.go | String | func (val Val) String() string {
return C.GoStringN((*C.char)(val.mv_data), C.int(val.mv_size))
} | go | func (val Val) String() string {
return C.GoStringN((*C.char)(val.mv_data), C.int(val.mv_size))
} | [
"func",
"(",
"val",
"Val",
")",
"String",
"(",
")",
"string",
"{",
"return",
"C",
".",
"GoStringN",
"(",
"(",
"*",
"C",
".",
"char",
")",
"(",
"val",
".",
"mv_data",
")",
",",
"C",
".",
"int",
"(",
"val",
".",
"mv_size",
")",
")",
"\n",
"}"
] | // If val is nil, an empty string is returned. | [
"If",
"val",
"is",
"nil",
"an",
"empty",
"string",
"is",
"returned",
"."
] | 9f9ffa97e793fb4d06a56e65a5e6b72cb3b32f1c | https://github.com/szferi/gomdb/blob/9f9ffa97e793fb4d06a56e65a5e6b72cb3b32f1c/val.go#L50-L52 |
145,736 | szferi/gomdb | env.go | NewEnv | func NewEnv() (*Env, error) {
var _env *C.MDB_env
ret := C.mdb_env_create(&_env)
if ret != SUCCESS {
return nil, errno(ret)
}
return &Env{_env}, nil
} | go | func NewEnv() (*Env, error) {
var _env *C.MDB_env
ret := C.mdb_env_create(&_env)
if ret != SUCCESS {
return nil, errno(ret)
}
return &Env{_env}, nil
} | [
"func",
"NewEnv",
"(",
")",
"(",
"*",
"Env",
",",
"error",
")",
"{",
"var",
"_env",
"*",
"C",
".",
"MDB_env",
"\n",
"ret",
":=",
"C",
".",
"mdb_env_create",
"(",
"&",
"_env",
")",
"\n",
"if",
"ret",
"!=",
"SUCCESS",
"{",
"return",
"nil",
",",
"... | // Create an MDB environment handle. | [
"Create",
"an",
"MDB",
"environment",
"handle",
"."
] | 9f9ffa97e793fb4d06a56e65a5e6b72cb3b32f1c | https://github.com/szferi/gomdb/blob/9f9ffa97e793fb4d06a56e65a5e6b72cb3b32f1c/env.go#L100-L107 |
145,737 | bennyscetbun/jsongo | jsongo.go | atMap | func (that *JSONNode) atMap(key string, val ...interface{}) *JSONNode {
if that.t != TypeUndefined && that.t != TypeMap {
panic(ErrorMultipleType)
}
if that.m == nil {
that.m = make(map[string]*JSONNode)
that.t = TypeMap
}
if next, ok := that.m[key]; ok {
return next.At(val...)
}
that.m[key] = new(JSONNo... | go | func (that *JSONNode) atMap(key string, val ...interface{}) *JSONNode {
if that.t != TypeUndefined && that.t != TypeMap {
panic(ErrorMultipleType)
}
if that.m == nil {
that.m = make(map[string]*JSONNode)
that.t = TypeMap
}
if next, ok := that.m[key]; ok {
return next.At(val...)
}
that.m[key] = new(JSONNo... | [
"func",
"(",
"that",
"*",
"JSONNode",
")",
"atMap",
"(",
"key",
"string",
",",
"val",
"...",
"interface",
"{",
"}",
")",
"*",
"JSONNode",
"{",
"if",
"that",
".",
"t",
"!=",
"TypeUndefined",
"&&",
"that",
".",
"t",
"!=",
"TypeMap",
"{",
"panic",
"("... | //atMap return the JSONNode in current map | [
"atMap",
"return",
"the",
"JSONNode",
"in",
"current",
"map"
] | 9624bef8c57b18467d7957fa19cd6c7392ec62eb | https://github.com/bennyscetbun/jsongo/blob/9624bef8c57b18467d7957fa19cd6c7392ec62eb/jsongo.go#L101-L114 |
145,738 | bennyscetbun/jsongo | jsongo.go | Len | func (that *JSONNode) Len() int {
var ret int
switch that.t {
case TypeMap:
ret = len(that.m)
case TypeArray:
ret = len(that.a)
case TypeValue:
ret = 1
}
return ret
} | go | func (that *JSONNode) Len() int {
var ret int
switch that.t {
case TypeMap:
ret = len(that.m)
case TypeArray:
ret = len(that.a)
case TypeValue:
ret = 1
}
return ret
} | [
"func",
"(",
"that",
"*",
"JSONNode",
")",
"Len",
"(",
")",
"int",
"{",
"var",
"ret",
"int",
"\n",
"switch",
"that",
".",
"t",
"{",
"case",
"TypeMap",
":",
"ret",
"=",
"len",
"(",
"that",
".",
"m",
")",
"\n",
"case",
"TypeArray",
":",
"ret",
"=... | //Len Return the length of the current Node
//
// if TypeUndefined return 0
//
// if TypeValue return 1
//
// if TypeArray return the size of the array
//
// if TypeMap return the size of the map | [
"Len",
"Return",
"the",
"length",
"of",
"the",
"current",
"Node",
"if",
"TypeUndefined",
"return",
"0",
"if",
"TypeValue",
"return",
"1",
"if",
"TypeArray",
"return",
"the",
"size",
"of",
"the",
"array",
"if",
"TypeMap",
"return",
"the",
"size",
"of",
"the... | 9624bef8c57b18467d7957fa19cd6c7392ec62eb | https://github.com/bennyscetbun/jsongo/blob/9624bef8c57b18467d7957fa19cd6c7392ec62eb/jsongo.go#L334-L345 |
145,739 | bennyscetbun/jsongo | jsongo.go | SetType | func (that *JSONNode) SetType(t JSONNodeType) *JSONNode {
if that.t != TypeUndefined && that.t != t {
panic(ErrorMultipleType)
}
if t >= typeError {
panic(ErrorUnknowType)
}
that.t = t
switch t {
case TypeMap:
that.m = make(map[string]*JSONNode, 0)
case TypeArray:
that.a = make([]JSONNode, 0)
case Type... | go | func (that *JSONNode) SetType(t JSONNodeType) *JSONNode {
if that.t != TypeUndefined && that.t != t {
panic(ErrorMultipleType)
}
if t >= typeError {
panic(ErrorUnknowType)
}
that.t = t
switch t {
case TypeMap:
that.m = make(map[string]*JSONNode, 0)
case TypeArray:
that.a = make([]JSONNode, 0)
case Type... | [
"func",
"(",
"that",
"*",
"JSONNode",
")",
"SetType",
"(",
"t",
"JSONNodeType",
")",
"*",
"JSONNode",
"{",
"if",
"that",
".",
"t",
"!=",
"TypeUndefined",
"&&",
"that",
".",
"t",
"!=",
"t",
"{",
"panic",
"(",
"ErrorMultipleType",
")",
"\n",
"}",
"\n",... | //SetType Is use to set the Type of a node and return the current Node you are working on | [
"SetType",
"Is",
"use",
"to",
"set",
"the",
"Type",
"of",
"a",
"node",
"and",
"return",
"the",
"current",
"Node",
"you",
"are",
"working",
"on"
] | 9624bef8c57b18467d7957fa19cd6c7392ec62eb | https://github.com/bennyscetbun/jsongo/blob/9624bef8c57b18467d7957fa19cd6c7392ec62eb/jsongo.go#L348-L365 |
145,740 | bennyscetbun/jsongo | jsongo.go | Copy | func (that *JSONNode) Copy(other *JSONNode, deepCopy bool) *JSONNode {
if that.t != TypeUndefined {
panic(ErrorCopyType)
}
if other.t == TypeValue {
*that = *other
} else if other.t == TypeArray {
if !deepCopy {
*that = *other
} else {
that.Array(len(other.a))
for i := range other.a {
that.At(... | go | func (that *JSONNode) Copy(other *JSONNode, deepCopy bool) *JSONNode {
if that.t != TypeUndefined {
panic(ErrorCopyType)
}
if other.t == TypeValue {
*that = *other
} else if other.t == TypeArray {
if !deepCopy {
*that = *other
} else {
that.Array(len(other.a))
for i := range other.a {
that.At(... | [
"func",
"(",
"that",
"*",
"JSONNode",
")",
"Copy",
"(",
"other",
"*",
"JSONNode",
",",
"deepCopy",
"bool",
")",
"*",
"JSONNode",
"{",
"if",
"that",
".",
"t",
"!=",
"TypeUndefined",
"{",
"panic",
"(",
"ErrorCopyType",
")",
"\n",
"}",
"\n\n",
"if",
"ot... | //Copy Will set this node like the one in argument. this node must be of type TypeUndefined
//
//if deepCopy is true we will copy all the children recursively else we will share the children
//
//return the current JSONNode | [
"Copy",
"Will",
"set",
"this",
"node",
"like",
"the",
"one",
"in",
"argument",
".",
"this",
"node",
"must",
"be",
"of",
"type",
"TypeUndefined",
"if",
"deepCopy",
"is",
"true",
"we",
"will",
"copy",
"all",
"the",
"children",
"recursively",
"else",
"we",
... | 9624bef8c57b18467d7957fa19cd6c7392ec62eb | https://github.com/bennyscetbun/jsongo/blob/9624bef8c57b18467d7957fa19cd6c7392ec62eb/jsongo.go#L377-L406 |
145,741 | bennyscetbun/jsongo | jsongo.go | DelKey | func (that *JSONNode) DelKey(key string) *JSONNode {
if that.t != TypeMap {
panic(ErrorDeleteKey)
}
delete(that.m, key)
return that
} | go | func (that *JSONNode) DelKey(key string) *JSONNode {
if that.t != TypeMap {
panic(ErrorDeleteKey)
}
delete(that.m, key)
return that
} | [
"func",
"(",
"that",
"*",
"JSONNode",
")",
"DelKey",
"(",
"key",
"string",
")",
"*",
"JSONNode",
"{",
"if",
"that",
".",
"t",
"!=",
"TypeMap",
"{",
"panic",
"(",
"ErrorDeleteKey",
")",
"\n",
"}",
"\n",
"delete",
"(",
"that",
".",
"m",
",",
"key",
... | //DelKey will remove a key in the map.
//
//return the current JSONNode. | [
"DelKey",
"will",
"remove",
"a",
"key",
"in",
"the",
"map",
".",
"return",
"the",
"current",
"JSONNode",
"."
] | 9624bef8c57b18467d7957fa19cd6c7392ec62eb | https://github.com/bennyscetbun/jsongo/blob/9624bef8c57b18467d7957fa19cd6c7392ec62eb/jsongo.go#L416-L422 |
145,742 | bennyscetbun/jsongo | jsongo.go | MarshalJSON | func (that *JSONNode) MarshalJSON() ([]byte, error) {
var ret []byte
var err error
switch that.t {
case TypeMap:
ret, err = json.Marshal(that.m)
case TypeArray:
ret, err = json.Marshal(that.a)
case TypeValue:
ret, err = json.Marshal(that.v)
default:
ret, err = json.Marshal(nil)
}
if err != nil {
retu... | go | func (that *JSONNode) MarshalJSON() ([]byte, error) {
var ret []byte
var err error
switch that.t {
case TypeMap:
ret, err = json.Marshal(that.m)
case TypeArray:
ret, err = json.Marshal(that.a)
case TypeValue:
ret, err = json.Marshal(that.v)
default:
ret, err = json.Marshal(nil)
}
if err != nil {
retu... | [
"func",
"(",
"that",
"*",
"JSONNode",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"ret",
"[",
"]",
"byte",
"\n",
"var",
"err",
"error",
"\n",
"switch",
"that",
".",
"t",
"{",
"case",
"TypeMap",
":",
"ret",
... | //MarshalJSON Make JSONNode a Marshaler Interface compatible | [
"MarshalJSON",
"Make",
"JSONNode",
"a",
"Marshaler",
"Interface",
"compatible"
] | 9624bef8c57b18467d7957fa19cd6c7392ec62eb | https://github.com/bennyscetbun/jsongo/blob/9624bef8c57b18467d7957fa19cd6c7392ec62eb/jsongo.go#L457-L474 |
145,743 | bennyscetbun/jsongo | jsongo.go | UnmarshalJSON | func (that *JSONNode) UnmarshalJSON(data []byte) error {
if len(data) == 0 {
return nil
}
if that.dontExpand && that.t == TypeUndefined {
return nil
}
if that.t == TypeValue {
return that.unmarshalValue(data)
}
if data[0] == '{' {
if that.t != TypeMap && that.t != TypeUndefined {
return ErrorTypeUnmar... | go | func (that *JSONNode) UnmarshalJSON(data []byte) error {
if len(data) == 0 {
return nil
}
if that.dontExpand && that.t == TypeUndefined {
return nil
}
if that.t == TypeValue {
return that.unmarshalValue(data)
}
if data[0] == '{' {
if that.t != TypeMap && that.t != TypeUndefined {
return ErrorTypeUnmar... | [
"func",
"(",
"that",
"*",
"JSONNode",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"len",
"(",
"data",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"that",
".",
"dontExpand",
"&&",
"that",
".",
"t"... | //UnmarshalJSON Make JSONNode a Unmarshaler Interface compatible | [
"UnmarshalJSON",
"Make",
"JSONNode",
"a",
"Unmarshaler",
"Interface",
"compatible"
] | 9624bef8c57b18467d7957fa19cd6c7392ec62eb | https://github.com/bennyscetbun/jsongo/blob/9624bef8c57b18467d7957fa19cd6c7392ec62eb/jsongo.go#L529-L556 |
145,744 | bennyscetbun/jsongo | debug.go | DebugPrint | func (that *JSONNode) DebugPrint(prefix string) {
asJSON, err := json.MarshalIndent(that, "", " ")
if err != nil {
fmt.Printf("%s\n", err.Error())
os.Exit(-1)
}
fmt.Printf("%s%s\n", prefix, asJSON)
} | go | func (that *JSONNode) DebugPrint(prefix string) {
asJSON, err := json.MarshalIndent(that, "", " ")
if err != nil {
fmt.Printf("%s\n", err.Error())
os.Exit(-1)
}
fmt.Printf("%s%s\n", prefix, asJSON)
} | [
"func",
"(",
"that",
"*",
"JSONNode",
")",
"DebugPrint",
"(",
"prefix",
"string",
")",
"{",
"asJSON",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"that",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
... | //DebugPrint Print a JSONNode as json withindent | [
"DebugPrint",
"Print",
"a",
"JSONNode",
"as",
"json",
"withindent"
] | 9624bef8c57b18467d7957fa19cd6c7392ec62eb | https://github.com/bennyscetbun/jsongo/blob/9624bef8c57b18467d7957fa19cd6c7392ec62eb/debug.go#L10-L17 |
145,745 | bennyscetbun/jsongo | print.go | UpperCamelCase | func UpperCamelCase(str string) string {
pieces := split(str)
for index, s := range pieces {
pieces[index] = fmt.Sprintf(`%v%v`, strings.ToUpper(string(s[0])), strings.ToLower(s[1:]))
}
return strings.Join(pieces, ``)
} | go | func UpperCamelCase(str string) string {
pieces := split(str)
for index, s := range pieces {
pieces[index] = fmt.Sprintf(`%v%v`, strings.ToUpper(string(s[0])), strings.ToLower(s[1:]))
}
return strings.Join(pieces, ``)
} | [
"func",
"UpperCamelCase",
"(",
"str",
"string",
")",
"string",
"{",
"pieces",
":=",
"split",
"(",
"str",
")",
"\n\n",
"for",
"index",
",",
"s",
":=",
"range",
"pieces",
"{",
"pieces",
"[",
"index",
"]",
"=",
"fmt",
".",
"Sprintf",
"(",
"`%v%v`",
",",... | // UpperCamelCase converts a string to it's upper camel case version. | [
"UpperCamelCase",
"converts",
"a",
"string",
"to",
"it",
"s",
"upper",
"camel",
"case",
"version",
"."
] | 9624bef8c57b18467d7957fa19cd6c7392ec62eb | https://github.com/bennyscetbun/jsongo/blob/9624bef8c57b18467d7957fa19cd6c7392ec62eb/print.go#L20-L28 |
145,746 | pivotal-cf/jhanda | command_set.go | Execute | func (cs CommandSet) Execute(command string, args []string) error {
cmd, ok := cs[command]
if !ok {
return fmt.Errorf("unknown command: %s", command)
}
for _, arg := range args {
if arg == "--help" || arg == "-h" || arg == "-help" {
return cs.Execute("help", []string{command})
}
}
err := cmd.Execute(ar... | go | func (cs CommandSet) Execute(command string, args []string) error {
cmd, ok := cs[command]
if !ok {
return fmt.Errorf("unknown command: %s", command)
}
for _, arg := range args {
if arg == "--help" || arg == "-h" || arg == "-help" {
return cs.Execute("help", []string{command})
}
}
err := cmd.Execute(ar... | [
"func",
"(",
"cs",
"CommandSet",
")",
"Execute",
"(",
"command",
"string",
",",
"args",
"[",
"]",
"string",
")",
"error",
"{",
"cmd",
",",
"ok",
":=",
"cs",
"[",
"command",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"... | // Execute will invoke the Execute method of the Command that matches the name
// provided as "command", passing "args". Execute will return an error in the
// case that the command cannot be found by the given name. | [
"Execute",
"will",
"invoke",
"the",
"Execute",
"method",
"of",
"the",
"Command",
"that",
"matches",
"the",
"name",
"provided",
"as",
"command",
"passing",
"args",
".",
"Execute",
"will",
"return",
"an",
"error",
"in",
"the",
"case",
"that",
"the",
"command",... | e6aa09a032df2c727b140f9c6fc4df15aeb2b645 | https://github.com/pivotal-cf/jhanda/blob/e6aa09a032df2c727b140f9c6fc4df15aeb2b645/command_set.go#L13-L31 |
145,747 | pivotal-cf/jhanda | command_set.go | Usage | func (cs CommandSet) Usage(command string) (Usage, error) {
cmd, ok := cs[command]
if !ok {
return Usage{}, fmt.Errorf("unknown command: %s", command)
}
return cmd.Usage(), nil
} | go | func (cs CommandSet) Usage(command string) (Usage, error) {
cmd, ok := cs[command]
if !ok {
return Usage{}, fmt.Errorf("unknown command: %s", command)
}
return cmd.Usage(), nil
} | [
"func",
"(",
"cs",
"CommandSet",
")",
"Usage",
"(",
"command",
"string",
")",
"(",
"Usage",
",",
"error",
")",
"{",
"cmd",
",",
"ok",
":=",
"cs",
"[",
"command",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"Usage",
"{",
"}",
",",
"fmt",
".",
"Er... | // Usage will return the Usage object of the Command that matches the name
// provided as "command". Usage will return an error in the case that the
// command cannot be found by the given name. | [
"Usage",
"will",
"return",
"the",
"Usage",
"object",
"of",
"the",
"Command",
"that",
"matches",
"the",
"name",
"provided",
"as",
"command",
".",
"Usage",
"will",
"return",
"an",
"error",
"in",
"the",
"case",
"that",
"the",
"command",
"cannot",
"be",
"found... | e6aa09a032df2c727b140f9c6fc4df15aeb2b645 | https://github.com/pivotal-cf/jhanda/blob/e6aa09a032df2c727b140f9c6fc4df15aeb2b645/command_set.go#L36-L43 |
145,748 | aead/poly1305 | poly1305_amd64.go | New | func New(key [32]byte) *Hash {
if useAVX2 {
h := new(poly1305HashAVX2)
initializeAVX2(&(h.state), &key)
return &Hash{h, false}
}
h := new(poly1305Hash)
initialize(&(h.state), &key)
return &Hash{h, false}
} | go | func New(key [32]byte) *Hash {
if useAVX2 {
h := new(poly1305HashAVX2)
initializeAVX2(&(h.state), &key)
return &Hash{h, false}
}
h := new(poly1305Hash)
initialize(&(h.state), &key)
return &Hash{h, false}
} | [
"func",
"New",
"(",
"key",
"[",
"32",
"]",
"byte",
")",
"*",
"Hash",
"{",
"if",
"useAVX2",
"{",
"h",
":=",
"new",
"(",
"poly1305HashAVX2",
")",
"\n",
"initializeAVX2",
"(",
"&",
"(",
"h",
".",
"state",
")",
",",
"&",
"key",
")",
"\n",
"return",
... | // New returns a Hash computing the poly1305 sum.
// Notice that Poly1305 is insecure if one key is used twice. | [
"New",
"returns",
"a",
"Hash",
"computing",
"the",
"poly1305",
"sum",
".",
"Notice",
"that",
"Poly1305",
"is",
"insecure",
"if",
"one",
"key",
"is",
"used",
"twice",
"."
] | 3fee0db0b63511234f7230da50b72414f6258f10 | https://github.com/aead/poly1305/blob/3fee0db0b63511234f7230da50b72414f6258f10/poly1305_amd64.go#L70-L79 |
145,749 | aead/poly1305 | poly1305_amd64.go | Sum | func (h *Hash) Sum(b []byte) []byte {
b = h.hash.Sum(b)
h.done = true
return b
} | go | func (h *Hash) Sum(b []byte) []byte {
b = h.hash.Sum(b)
h.done = true
return b
} | [
"func",
"(",
"h",
"*",
"Hash",
")",
"Sum",
"(",
"b",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"b",
"=",
"h",
".",
"hash",
".",
"Sum",
"(",
"b",
")",
"\n",
"h",
".",
"done",
"=",
"true",
"\n",
"return",
"b",
"\n",
"}"
] | // Sum appends the Poly1305 hash of the previously
// processed data to b and returns the resulting slice.
// It is safe to call this function multiple times. | [
"Sum",
"appends",
"the",
"Poly1305",
"hash",
"of",
"the",
"previously",
"processed",
"data",
"to",
"b",
"and",
"returns",
"the",
"resulting",
"slice",
".",
"It",
"is",
"safe",
"to",
"call",
"this",
"function",
"multiple",
"times",
"."
] | 3fee0db0b63511234f7230da50b72414f6258f10 | https://github.com/aead/poly1305/blob/3fee0db0b63511234f7230da50b72414f6258f10/poly1305_amd64.go#L107-L111 |
145,750 | aead/poly1305 | poly1305_ref.go | New | func New(key [32]byte) *Hash {
p := new(Hash)
initialize(&(p.r), &(p.s), &key)
return p
} | go | func New(key [32]byte) *Hash {
p := new(Hash)
initialize(&(p.r), &(p.s), &key)
return p
} | [
"func",
"New",
"(",
"key",
"[",
"32",
"]",
"byte",
")",
"*",
"Hash",
"{",
"p",
":=",
"new",
"(",
"Hash",
")",
"\n",
"initialize",
"(",
"&",
"(",
"p",
".",
"r",
")",
",",
"&",
"(",
"p",
".",
"s",
")",
",",
"&",
"key",
")",
"\n",
"return",
... | // New returns a hash.Hash computing the poly1305 sum.
// Notice that Poly1305 is insecure if one key is used twice. | [
"New",
"returns",
"a",
"hash",
".",
"Hash",
"computing",
"the",
"poly1305",
"sum",
".",
"Notice",
"that",
"Poly1305",
"is",
"insecure",
"if",
"one",
"key",
"is",
"used",
"twice",
"."
] | 3fee0db0b63511234f7230da50b72414f6258f10 | https://github.com/aead/poly1305/blob/3fee0db0b63511234f7230da50b72414f6258f10/poly1305_ref.go#L46-L50 |
145,751 | aead/poly1305 | poly1305_ref.go | Sum | func (p *Hash) Sum(b []byte) []byte {
var out [TagSize]byte
h := p.h
if p.off > 0 {
var buf [TagSize]byte
copy(buf[:], p.buf[:p.off])
buf[p.off] = 1 // invariant: p.off < TagSize
update(buf[:], finalBlock, &h, &(p.r))
}
finalize(&out, &h, &(p.s))
p.done = true
return append(b, out[:]...)
} | go | func (p *Hash) Sum(b []byte) []byte {
var out [TagSize]byte
h := p.h
if p.off > 0 {
var buf [TagSize]byte
copy(buf[:], p.buf[:p.off])
buf[p.off] = 1 // invariant: p.off < TagSize
update(buf[:], finalBlock, &h, &(p.r))
}
finalize(&out, &h, &(p.s))
p.done = true
return append(b, out[:]...)
} | [
"func",
"(",
"p",
"*",
"Hash",
")",
"Sum",
"(",
"b",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"var",
"out",
"[",
"TagSize",
"]",
"byte",
"\n",
"h",
":=",
"p",
".",
"h",
"\n\n",
"if",
"p",
".",
"off",
">",
"0",
"{",
"var",
"buf",
"[",... | // Sum appends the Pol1305 hash of the previously
// processed data to b and returns the resulting slice.
// It is safe to call this function multiple times. | [
"Sum",
"appends",
"the",
"Pol1305",
"hash",
"of",
"the",
"previously",
"processed",
"data",
"to",
"b",
"and",
"returns",
"the",
"resulting",
"slice",
".",
"It",
"is",
"safe",
"to",
"call",
"this",
"function",
"multiple",
"times",
"."
] | 3fee0db0b63511234f7230da50b72414f6258f10 | https://github.com/aead/poly1305/blob/3fee0db0b63511234f7230da50b72414f6258f10/poly1305_ref.go#L106-L121 |
145,752 | josephspurrier/csrfbanana | token.go | Clear | func Clear(w http.ResponseWriter, r *http.Request, sess *sessions.Session) {
// Delete the map if it doesn't exist
if _, ok := sess.Values[TokenName]; ok {
delete(sess.Values, TokenName)
sess.Save(r, w)
}
} | go | func Clear(w http.ResponseWriter, r *http.Request, sess *sessions.Session) {
// Delete the map if it doesn't exist
if _, ok := sess.Values[TokenName]; ok {
delete(sess.Values, TokenName)
sess.Save(r, w)
}
} | [
"func",
"Clear",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"sess",
"*",
"sessions",
".",
"Session",
")",
"{",
"// Delete the map if it doesn't exist",
"if",
"_",
",",
"ok",
":=",
"sess",
".",
"Values",
"[",
"Tok... | // Clear will remove all the tokens. Call after a permission change. | [
"Clear",
"will",
"remove",
"all",
"the",
"tokens",
".",
"Call",
"after",
"a",
"permission",
"change",
"."
] | 2c49e35971765ef67306072ff7daa0e8d9262ff0 | https://github.com/josephspurrier/csrfbanana/blob/2c49e35971765ef67306072ff7daa0e8d9262ff0/token.go#L31-L37 |
145,753 | josephspurrier/csrfbanana | token.go | Token | func Token(w http.ResponseWriter, r *http.Request, sess *sessions.Session) string {
// Generate the map if it doesn't exist
if _, ok := sess.Values[TokenName]; !ok {
sess.Values[TokenName] = make(StringMap)
}
path := r.URL.Path
if SingleToken {
path = "/"
}
sessMap := sess.Values[TokenName].(StringMap)
i... | go | func Token(w http.ResponseWriter, r *http.Request, sess *sessions.Session) string {
// Generate the map if it doesn't exist
if _, ok := sess.Values[TokenName]; !ok {
sess.Values[TokenName] = make(StringMap)
}
path := r.URL.Path
if SingleToken {
path = "/"
}
sessMap := sess.Values[TokenName].(StringMap)
i... | [
"func",
"Token",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"sess",
"*",
"sessions",
".",
"Session",
")",
"string",
"{",
"// Generate the map if it doesn't exist",
"if",
"_",
",",
"ok",
":=",
"sess",
".",
"Values",... | // Token will return a token. If SingleToken = true, it will return the same token for every page. | [
"Token",
"will",
"return",
"a",
"token",
".",
"If",
"SingleToken",
"=",
"true",
"it",
"will",
"return",
"the",
"same",
"token",
"for",
"every",
"page",
"."
] | 2c49e35971765ef67306072ff7daa0e8d9262ff0 | https://github.com/josephspurrier/csrfbanana/blob/2c49e35971765ef67306072ff7daa0e8d9262ff0/token.go#L40-L66 |
145,754 | josephspurrier/csrfbanana | token.go | TokenWithPath | func TokenWithPath(w http.ResponseWriter, r *http.Request, sess *sessions.Session, urlPath string) string {
// Generate the map if it doesn't exist
if _, ok := sess.Values[TokenName]; !ok {
sess.Values[TokenName] = make(StringMap)
}
sessMap := sess.Values[TokenName].(StringMap)
if _, ok := sessMap[urlPath]; !ok... | go | func TokenWithPath(w http.ResponseWriter, r *http.Request, sess *sessions.Session, urlPath string) string {
// Generate the map if it doesn't exist
if _, ok := sess.Values[TokenName]; !ok {
sess.Values[TokenName] = make(StringMap)
}
sessMap := sess.Values[TokenName].(StringMap)
if _, ok := sessMap[urlPath]; !ok... | [
"func",
"TokenWithPath",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"sess",
"*",
"sessions",
".",
"Session",
",",
"urlPath",
"string",
")",
"string",
"{",
"// Generate the map if it doesn't exist",
"if",
"_",
",",
"o... | // Token will return a token for the specified URL. SingleToken is ignored. | [
"Token",
"will",
"return",
"a",
"token",
"for",
"the",
"specified",
"URL",
".",
"SingleToken",
"is",
"ignored",
"."
] | 2c49e35971765ef67306072ff7daa0e8d9262ff0 | https://github.com/josephspurrier/csrfbanana/blob/2c49e35971765ef67306072ff7daa0e8d9262ff0/token.go#L69-L89 |
145,755 | josephspurrier/csrfbanana | token.go | match | func match(r *http.Request, sess *sessions.Session, refresh bool) bool {
valid := false
path := r.URL.Path
if SingleToken {
path = "/"
}
// If tokens exists
if token, ok := sess.Values[TokenName]; ok {
// Token submitted via POST
sentToken := r.FormValue(TokenName)
// Detect the content type
switch... | go | func match(r *http.Request, sess *sessions.Session, refresh bool) bool {
valid := false
path := r.URL.Path
if SingleToken {
path = "/"
}
// If tokens exists
if token, ok := sess.Values[TokenName]; ok {
// Token submitted via POST
sentToken := r.FormValue(TokenName)
// Detect the content type
switch... | [
"func",
"match",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"sess",
"*",
"sessions",
".",
"Session",
",",
"refresh",
"bool",
")",
"bool",
"{",
"valid",
":=",
"false",
"\n",
"path",
":=",
"r",
".",
"URL",
".",
"Path",
"\n\n",
"if",
"SingleToken",
"... | // If the form token matches the session token for the URL, return true | [
"If",
"the",
"form",
"token",
"matches",
"the",
"session",
"token",
"for",
"the",
"URL",
"return",
"true"
] | 2c49e35971765ef67306072ff7daa0e8d9262ff0 | https://github.com/josephspurrier/csrfbanana/blob/2c49e35971765ef67306072ff7daa0e8d9262ff0/token.go#L105-L174 |
145,756 | josephspurrier/csrfbanana | csrfbanana.go | New | func New(next http.Handler, sessStore sessions.Store, sessName string) *CSRFHandler {
cs := &CSRFHandler{}
cs.nextHandler = next
cs.failureHandler = http.HandlerFunc(defaultFailureHandler)
cs.store = sessStore
cs.sessionName = sessName
return cs
} | go | func New(next http.Handler, sessStore sessions.Store, sessName string) *CSRFHandler {
cs := &CSRFHandler{}
cs.nextHandler = next
cs.failureHandler = http.HandlerFunc(defaultFailureHandler)
cs.store = sessStore
cs.sessionName = sessName
return cs
} | [
"func",
"New",
"(",
"next",
"http",
".",
"Handler",
",",
"sessStore",
"sessions",
".",
"Store",
",",
"sessName",
"string",
")",
"*",
"CSRFHandler",
"{",
"cs",
":=",
"&",
"CSRFHandler",
"{",
"}",
"\n",
"cs",
".",
"nextHandler",
"=",
"next",
"\n",
"cs",
... | // New can be used as middleware because it returns an http.HandlerFunc | [
"New",
"can",
"be",
"used",
"as",
"middleware",
"because",
"it",
"returns",
"an",
"http",
".",
"HandlerFunc"
] | 2c49e35971765ef67306072ff7daa0e8d9262ff0 | https://github.com/josephspurrier/csrfbanana/blob/2c49e35971765ef67306072ff7daa0e8d9262ff0/csrfbanana.go#L40-L47 |
145,757 | josephspurrier/csrfbanana | csrfbanana.go | ExcludeRegexPaths | func (h *CSRFHandler) ExcludeRegexPaths(strings []string) {
for _, re := range strings {
compiled := regexp.MustCompile(re)
h.excludeRegexPaths = append(h.excludeRegexPaths, compiled)
}
} | go | func (h *CSRFHandler) ExcludeRegexPaths(strings []string) {
for _, re := range strings {
compiled := regexp.MustCompile(re)
h.excludeRegexPaths = append(h.excludeRegexPaths, compiled)
}
} | [
"func",
"(",
"h",
"*",
"CSRFHandler",
")",
"ExcludeRegexPaths",
"(",
"strings",
"[",
"]",
"string",
")",
"{",
"for",
"_",
",",
"re",
":=",
"range",
"strings",
"{",
"compiled",
":=",
"regexp",
".",
"MustCompile",
"(",
"re",
")",
"\n",
"h",
".",
"exclu... | // ExcludeRegexPath excludes a list of paths from the token middleware | [
"ExcludeRegexPath",
"excludes",
"a",
"list",
"of",
"paths",
"from",
"the",
"token",
"middleware"
] | 2c49e35971765ef67306072ff7daa0e8d9262ff0 | https://github.com/josephspurrier/csrfbanana/blob/2c49e35971765ef67306072ff7daa0e8d9262ff0/csrfbanana.go#L55-L60 |
145,758 | josephspurrier/csrfbanana | csrfbanana.go | ServeHTTP | func (h *CSRFHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if !h.isExempt(r.URL.Path) {
// *********************************************************************
// Source: https://github.com/justinas/nosurf/blob/master/handler.go
// MIT License in nosurf.go
//
// if the request is secure, we ... | go | func (h *CSRFHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if !h.isExempt(r.URL.Path) {
// *********************************************************************
// Source: https://github.com/justinas/nosurf/blob/master/handler.go
// MIT License in nosurf.go
//
// if the request is secure, we ... | [
"func",
"(",
"h",
"*",
"CSRFHandler",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"!",
"h",
".",
"isExempt",
"(",
"r",
".",
"URL",
".",
"Path",
")",
"{",
"// **********************... | // ServeHTTP will valid a token and it is does not match, it will show the FailureHandler | [
"ServeHTTP",
"will",
"valid",
"a",
"token",
"and",
"it",
"is",
"does",
"not",
"match",
"it",
"will",
"show",
"the",
"FailureHandler"
] | 2c49e35971765ef67306072ff7daa0e8d9262ff0 | https://github.com/josephspurrier/csrfbanana/blob/2c49e35971765ef67306072ff7daa0e8d9262ff0/csrfbanana.go#L68-L118 |
145,759 | josephspurrier/csrfbanana | csrfbanana.go | isExempt | func (h *CSRFHandler) isExempt(url string) bool {
for _, re := range h.excludeRegexPaths {
if re.MatchString(url) {
return true
}
}
return false
} | go | func (h *CSRFHandler) isExempt(url string) bool {
for _, re := range h.excludeRegexPaths {
if re.MatchString(url) {
return true
}
}
return false
} | [
"func",
"(",
"h",
"*",
"CSRFHandler",
")",
"isExempt",
"(",
"url",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"re",
":=",
"range",
"h",
".",
"excludeRegexPaths",
"{",
"if",
"re",
".",
"MatchString",
"(",
"url",
")",
"{",
"return",
"true",
"\n",
"... | // Returns true if the current request is exempt | [
"Returns",
"true",
"if",
"the",
"current",
"request",
"is",
"exempt"
] | 2c49e35971765ef67306072ff7daa0e8d9262ff0 | https://github.com/josephspurrier/csrfbanana/blob/2c49e35971765ef67306072ff7daa0e8d9262ff0/csrfbanana.go#L121-L128 |
145,760 | josephspurrier/csrfbanana | example/example.go | routeLogin | func routeLogin(w http.ResponseWriter, r *http.Request) {
// Get session
sess := Session(r, SessionName)
// Create a map for the template
vars := make(map[string]string)
// Store the CSRF token
vars["token"] = csrfbanana.Token(w, r, sess)
// If a POST operation
if r.Method == "POST" {
// Store the name to... | go | func routeLogin(w http.ResponseWriter, r *http.Request) {
// Get session
sess := Session(r, SessionName)
// Create a map for the template
vars := make(map[string]string)
// Store the CSRF token
vars["token"] = csrfbanana.Token(w, r, sess)
// If a POST operation
if r.Method == "POST" {
// Store the name to... | [
"func",
"routeLogin",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"// Get session",
"sess",
":=",
"Session",
"(",
"r",
",",
"SessionName",
")",
"\n\n",
"// Create a map for the template",
"vars",
":=",
"make",
"(... | // Login handles GET and POST | [
"Login",
"handles",
"GET",
"and",
"POST"
] | 2c49e35971765ef67306072ff7daa0e8d9262ff0 | https://github.com/josephspurrier/csrfbanana/blob/2c49e35971765ef67306072ff7daa0e8d9262ff0/example/example.go#L57-L76 |
145,761 | josephspurrier/csrfbanana | example/example.go | routeInvalidToken | func routeInvalidToken(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html")
w.WriteHeader(http.StatusForbidden)
fmt.Fprint(w, `Your token <strong>expired</strong>, click <a href="javascript:void(0)" onclick="window.history.back()">here</a> to try again.`)
} | go | func routeInvalidToken(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html")
w.WriteHeader(http.StatusForbidden)
fmt.Fprint(w, `Your token <strong>expired</strong>, click <a href="javascript:void(0)" onclick="window.history.back()">here</a> to try again.`)
} | [
"func",
"routeInvalidToken",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"w",
".",
"WriteHeader",
"(",
"http",
".... | // InvalidToken handles CSRF attacks | [
"InvalidToken",
"handles",
"CSRF",
"attacks"
] | 2c49e35971765ef67306072ff7daa0e8d9262ff0 | https://github.com/josephspurrier/csrfbanana/blob/2c49e35971765ef67306072ff7daa0e8d9262ff0/example/example.go#L79-L83 |
145,762 | josephspurrier/csrfbanana | example/example.go | Session | func Session(r *http.Request, name string) *sessions.Session {
session, _ := Store.Get(r, name)
return session
} | go | func Session(r *http.Request, name string) *sessions.Session {
session, _ := Store.Get(r, name)
return session
} | [
"func",
"Session",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"name",
"string",
")",
"*",
"sessions",
".",
"Session",
"{",
"session",
",",
"_",
":=",
"Store",
".",
"Get",
"(",
"r",
",",
"name",
")",
"\n",
"return",
"session",
"\n",
"}"
] | // Session returns a new session, never returns an error | [
"Session",
"returns",
"a",
"new",
"session",
"never",
"returns",
"an",
"error"
] | 2c49e35971765ef67306072ff7daa0e8d9262ff0 | https://github.com/josephspurrier/csrfbanana/blob/2c49e35971765ef67306072ff7daa0e8d9262ff0/example/example.go#L86-L89 |
145,763 | prasmussen/gandi-api | domain/domain.go | Available | func (self *Domain) Available(name string) (string, error) {
var result map[string]interface{}
domain := []string{name}
params := []interface{}{self.Key, domain}
if err := self.Call("domain.available", params, &result); err != nil {
return "", err
}
return result[name].(string), nil
} | go | func (self *Domain) Available(name string) (string, error) {
var result map[string]interface{}
domain := []string{name}
params := []interface{}{self.Key, domain}
if err := self.Call("domain.available", params, &result); err != nil {
return "", err
}
return result[name].(string), nil
} | [
"func",
"(",
"self",
"*",
"Domain",
")",
"Available",
"(",
"name",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"result",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n",
"domain",
":=",
"[",
"]",
"string",
"{",
"name",
"}",
... | // Check the availability of some domain | [
"Check",
"the",
"availability",
"of",
"some",
"domain"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/domain/domain.go#L17-L25 |
145,764 | prasmussen/gandi-api | domain/domain.go | Info | func (self *Domain) Info(name string) (*DomainInfo, error) {
var res map[string]interface{}
params := []interface{}{self.Key, name}
if err := self.Call("domain.info", params, &res); err != nil {
return nil, err
}
return ToDomainInfo(res), nil
} | go | func (self *Domain) Info(name string) (*DomainInfo, error) {
var res map[string]interface{}
params := []interface{}{self.Key, name}
if err := self.Call("domain.info", params, &res); err != nil {
return nil, err
}
return ToDomainInfo(res), nil
} | [
"func",
"(",
"self",
"*",
"Domain",
")",
"Info",
"(",
"name",
"string",
")",
"(",
"*",
"DomainInfo",
",",
"error",
")",
"{",
"var",
"res",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n",
"params",
":=",
"[",
"]",
"interface",
"{",
"}",
"{... | // Get domain information | [
"Get",
"domain",
"information"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/domain/domain.go#L28-L35 |
145,765 | prasmussen/gandi-api | domain/domain.go | Create | func (self *Domain) Create(name, contactHandle string, years int64) (*operation.OperationInfo, error) {
var res map[string]interface{}
createArgs := map[string]interface{}{
"admin": contactHandle,
"bill": contactHandle,
"owner": contactHandle,
"tech": contactHandle,
"duration": years,
}
para... | go | func (self *Domain) Create(name, contactHandle string, years int64) (*operation.OperationInfo, error) {
var res map[string]interface{}
createArgs := map[string]interface{}{
"admin": contactHandle,
"bill": contactHandle,
"owner": contactHandle,
"tech": contactHandle,
"duration": years,
}
para... | [
"func",
"(",
"self",
"*",
"Domain",
")",
"Create",
"(",
"name",
",",
"contactHandle",
"string",
",",
"years",
"int64",
")",
"(",
"*",
"operation",
".",
"OperationInfo",
",",
"error",
")",
"{",
"var",
"res",
"map",
"[",
"string",
"]",
"interface",
"{",
... | // Create a domain | [
"Create",
"a",
"domain"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/domain/domain.go#L73-L87 |
145,766 | prasmussen/gandi-api | live_dns/domain/domain.go | Info | func (d *Domain) Info(name string) (infos *Info, err error) {
_, err = d.Get(fmt.Sprintf("/domains/%s", name), &infos)
return
} | go | func (d *Domain) Info(name string) (infos *Info, err error) {
_, err = d.Get(fmt.Sprintf("/domains/%s", name), &infos)
return
} | [
"func",
"(",
"d",
"*",
"Domain",
")",
"Info",
"(",
"name",
"string",
")",
"(",
"infos",
"*",
"Info",
",",
"err",
"error",
")",
"{",
"_",
",",
"err",
"=",
"d",
".",
"Get",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"name",
")",
",",
"... | // Info Gets domain information | [
"Info",
"Gets",
"domain",
"information"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/live_dns/domain/domain.go#L27-L30 |
145,767 | prasmussen/gandi-api | live_dns/domain/domain.go | Records | func (d *Domain) Records(name string) record.Manager {
return record.New(d.Client, fmt.Sprintf("/domains/%s", name))
} | go | func (d *Domain) Records(name string) record.Manager {
return record.New(d.Client, fmt.Sprintf("/domains/%s", name))
} | [
"func",
"(",
"d",
"*",
"Domain",
")",
"Records",
"(",
"name",
"string",
")",
"record",
".",
"Manager",
"{",
"return",
"record",
".",
"New",
"(",
"d",
".",
"Client",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"name",
")",
")",
"\n",
"}"
] | // Records gets a record client for the current domain | [
"Records",
"gets",
"a",
"record",
"client",
"for",
"the",
"current",
"domain"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/live_dns/domain/domain.go#L33-L35 |
145,768 | prasmussen/gandi-api | domain/zone/zone.go | Info | func (self *Zone) Info(id int64) (*ZoneInfo, error) {
var res map[string]interface{}
params := []interface{}{self.Key, id}
if err := self.Call("domain.zone.info", params, &res); err != nil {
return nil, err
}
return ToZoneInfo(res), nil
} | go | func (self *Zone) Info(id int64) (*ZoneInfo, error) {
var res map[string]interface{}
params := []interface{}{self.Key, id}
if err := self.Call("domain.zone.info", params, &res); err != nil {
return nil, err
}
return ToZoneInfo(res), nil
} | [
"func",
"(",
"self",
"*",
"Zone",
")",
"Info",
"(",
"id",
"int64",
")",
"(",
"*",
"ZoneInfo",
",",
"error",
")",
"{",
"var",
"res",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n",
"params",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"s... | // Get zone information | [
"Get",
"zone",
"information"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/domain/zone/zone.go#L27-L34 |
145,769 | prasmussen/gandi-api | domain/zone/zone.go | Create | func (self *Zone) Create(name string) (*ZoneInfo, error) {
var res map[string]interface{}
createArgs := map[string]interface{}{"name": name}
params := []interface{}{self.Key, createArgs}
if err := self.Call("domain.zone.create", params, &res); err != nil {
return nil, err
}
return ToZoneInfo(res), nil
} | go | func (self *Zone) Create(name string) (*ZoneInfo, error) {
var res map[string]interface{}
createArgs := map[string]interface{}{"name": name}
params := []interface{}{self.Key, createArgs}
if err := self.Call("domain.zone.create", params, &res); err != nil {
return nil, err
}
return ToZoneInfo(res), nil
} | [
"func",
"(",
"self",
"*",
"Zone",
")",
"Create",
"(",
"name",
"string",
")",
"(",
"*",
"ZoneInfo",
",",
"error",
")",
"{",
"var",
"res",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n",
"createArgs",
":=",
"map",
"[",
"string",
"]",
"interfa... | // Create a zone | [
"Create",
"a",
"zone"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/domain/zone/zone.go#L53-L61 |
145,770 | prasmussen/gandi-api | domain/zone/zone.go | Delete | func (self *Zone) Delete(id int64) (bool, error) {
var res bool
params := []interface{}{self.Key, id}
if err := self.Call("domain.zone.delete", params, &res); err != nil {
return false, err
}
return res, nil
} | go | func (self *Zone) Delete(id int64) (bool, error) {
var res bool
params := []interface{}{self.Key, id}
if err := self.Call("domain.zone.delete", params, &res); err != nil {
return false, err
}
return res, nil
} | [
"func",
"(",
"self",
"*",
"Zone",
")",
"Delete",
"(",
"id",
"int64",
")",
"(",
"bool",
",",
"error",
")",
"{",
"var",
"res",
"bool",
"\n",
"params",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"self",
".",
"Key",
",",
"id",
"}",
"\n",
"if",
"... | // Delete a zone | [
"Delete",
"a",
"zone"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/domain/zone/zone.go#L64-L71 |
145,771 | prasmussen/gandi-api | live_dns/record/record.go | New | func New(c *client.Client, prefix string) *Record {
return &Record{c, prefix}
} | go | func New(c *client.Client, prefix string) *Record {
return &Record{c, prefix}
} | [
"func",
"New",
"(",
"c",
"*",
"client",
".",
"Client",
",",
"prefix",
"string",
")",
"*",
"Record",
"{",
"return",
"&",
"Record",
"{",
"c",
",",
"prefix",
"}",
"\n",
"}"
] | // New instanciates a new instance of a Zone client | [
"New",
"instanciates",
"a",
"new",
"instance",
"of",
"a",
"Zone",
"client"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/live_dns/record/record.go#L73-L75 |
145,772 | CAFxX/gcnotifier | gcnotifier.go | New | func New() *GCNotifier {
n := &gcnotifier{
gcCh: make(chan struct{}, 1),
doneCh: make(chan struct{}, 1),
}
// sentinel is dead immediately after the call to SetFinalizer
runtime.SetFinalizer(&sentinel{gcCh: n.gcCh, doneCh: n.doneCh}, finalizer)
// n will be dead when the GCNotifier that wraps it (see the ret... | go | func New() *GCNotifier {
n := &gcnotifier{
gcCh: make(chan struct{}, 1),
doneCh: make(chan struct{}, 1),
}
// sentinel is dead immediately after the call to SetFinalizer
runtime.SetFinalizer(&sentinel{gcCh: n.gcCh, doneCh: n.doneCh}, finalizer)
// n will be dead when the GCNotifier that wraps it (see the ret... | [
"func",
"New",
"(",
")",
"*",
"GCNotifier",
"{",
"n",
":=",
"&",
"gcnotifier",
"{",
"gcCh",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
",",
"1",
")",
",",
"doneCh",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
",",
"1",
")",
",",
"}",
"\n... | // New creates and arms a new GCNotifier. | [
"New",
"creates",
"and",
"arms",
"a",
"new",
"GCNotifier",
"."
] | 224a280d589d7a942006e27e9c87b60084b02228 | https://github.com/CAFxX/gcnotifier/blob/224a280d589d7a942006e27e9c87b60084b02228/gcnotifier.go#L71-L83 |
145,773 | prasmussen/gandi-api | client/client.go | New | func New(apiKey string, system SystemType) *Client {
return &Client{
Key: apiKey,
Url: system.Url(),
}
} | go | func New(apiKey string, system SystemType) *Client {
return &Client{
Key: apiKey,
Url: system.Url(),
}
} | [
"func",
"New",
"(",
"apiKey",
"string",
",",
"system",
"SystemType",
")",
"*",
"Client",
"{",
"return",
"&",
"Client",
"{",
"Key",
":",
"apiKey",
",",
"Url",
":",
"system",
".",
"Url",
"(",
")",
",",
"}",
"\n",
"}"
] | // New creates a new gandi client for the given system | [
"New",
"creates",
"a",
"new",
"gandi",
"client",
"for",
"the",
"given",
"system"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/client/client.go#L51-L56 |
145,774 | prasmussen/gandi-api | client/client.go | Call | func (c *Client) Call(serviceMethod string, args []interface{}, reply interface{}) error {
rpc, err := xmlrpc.NewClient(c.Url, nil)
if err != nil {
return err
}
return rpc.Call(serviceMethod, args, reply)
} | go | func (c *Client) Call(serviceMethod string, args []interface{}, reply interface{}) error {
rpc, err := xmlrpc.NewClient(c.Url, nil)
if err != nil {
return err
}
return rpc.Call(serviceMethod, args, reply)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Call",
"(",
"serviceMethod",
"string",
",",
"args",
"[",
"]",
"interface",
"{",
"}",
",",
"reply",
"interface",
"{",
"}",
")",
"error",
"{",
"rpc",
",",
"err",
":=",
"xmlrpc",
".",
"NewClient",
"(",
"c",
".",
... | // Call performs an acual XML RPC call to the gandi API | [
"Call",
"performs",
"an",
"acual",
"XML",
"RPC",
"call",
"to",
"the",
"gandi",
"API"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/client/client.go#L59-L65 |
145,775 | prasmussen/gandi-api | client/client.go | DoRest | func (c *Client) DoRest(req *http.Request, decoded interface{}) (*http.Response, error) {
if decoded != nil {
req.Header.Set("Accept", "application/json")
}
client := http.Client{}
resp, err := client.Do(req)
if err != nil {
return nil, err
}
if resp.StatusCode == http.StatusUnauthorized {
return nil, fmt.... | go | func (c *Client) DoRest(req *http.Request, decoded interface{}) (*http.Response, error) {
if decoded != nil {
req.Header.Set("Accept", "application/json")
}
client := http.Client{}
resp, err := client.Do(req)
if err != nil {
return nil, err
}
if resp.StatusCode == http.StatusUnauthorized {
return nil, fmt.... | [
"func",
"(",
"c",
"*",
"Client",
")",
"DoRest",
"(",
"req",
"*",
"http",
".",
"Request",
",",
"decoded",
"interface",
"{",
"}",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"if",
"decoded",
"!=",
"nil",
"{",
"req",
".",
"Header... | // DoRest performs a request to gandi LiveDNS api and optionnally decodes the reply | [
"DoRest",
"performs",
"a",
"request",
"to",
"gandi",
"LiveDNS",
"api",
"and",
"optionnally",
"decodes",
"the",
"reply"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/client/client.go#L68-L99 |
145,776 | prasmussen/gandi-api | client/client.go | NewJSONRequest | func (c *Client) NewJSONRequest(method string, url string, data interface{}) (*http.Request, error) {
var reader io.Reader
if data != nil {
b, err := json.Marshal(data)
if err != nil {
return nil, err
}
reader = bytes.NewReader(b)
}
req, err := http.NewRequest(method, fmt.Sprintf("%s/%s", strings.TrimRig... | go | func (c *Client) NewJSONRequest(method string, url string, data interface{}) (*http.Request, error) {
var reader io.Reader
if data != nil {
b, err := json.Marshal(data)
if err != nil {
return nil, err
}
reader = bytes.NewReader(b)
}
req, err := http.NewRequest(method, fmt.Sprintf("%s/%s", strings.TrimRig... | [
"func",
"(",
"c",
"*",
"Client",
")",
"NewJSONRequest",
"(",
"method",
"string",
",",
"url",
"string",
",",
"data",
"interface",
"{",
"}",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"var",
"reader",
"io",
".",
"Reader",
"\n",
"i... | // NewJSONRequest creates a new authenticated to gandi live DNS REST API.
// If data is not null, it will be encoded as json and prodived in the request body | [
"NewJSONRequest",
"creates",
"a",
"new",
"authenticated",
"to",
"gandi",
"live",
"DNS",
"REST",
"API",
".",
"If",
"data",
"is",
"not",
"null",
"it",
"will",
"be",
"encoded",
"as",
"json",
"and",
"prodived",
"in",
"the",
"request",
"body"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/client/client.go#L103-L121 |
145,777 | prasmussen/gandi-api | client/client.go | Get | func (c *Client) Get(URI string, decoded interface{}) (*http.Response, error) {
req, err := c.NewJSONRequest("GET", URI, nil)
if err != nil {
return nil, err
}
resp, err := c.DoRest(req, decoded)
if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("Unexpected http... | go | func (c *Client) Get(URI string, decoded interface{}) (*http.Response, error) {
req, err := c.NewJSONRequest("GET", URI, nil)
if err != nil {
return nil, err
}
resp, err := c.DoRest(req, decoded)
if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("Unexpected http... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Get",
"(",
"URI",
"string",
",",
"decoded",
"interface",
"{",
"}",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"c",
".",
"NewJSONRequest",
"(",
"\"",
"\"",
",",
... | // Get performs a Get request to gandi Live DNS api and decodes the returned data if a not null decoded pointer is provided | [
"Get",
"performs",
"a",
"Get",
"request",
"to",
"gandi",
"Live",
"DNS",
"api",
"and",
"decodes",
"the",
"returned",
"data",
"if",
"a",
"not",
"null",
"decoded",
"pointer",
"is",
"provided"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/client/client.go#L124-L137 |
145,778 | prasmussen/gandi-api | client/client.go | Post | func (c *Client) Post(URI string, data interface{}, decoded interface{}) (*http.Response, error) {
if debug {
fmt.Printf("DEBUG: POST URI=%s\n", URI)
}
req, err := c.NewJSONRequest("POST", URI, data)
if err != nil {
return nil, err
}
if debug {
fmt.Printf("DEBUG: POST req=%v decoded=%v\n", req, decoded)
}
... | go | func (c *Client) Post(URI string, data interface{}, decoded interface{}) (*http.Response, error) {
if debug {
fmt.Printf("DEBUG: POST URI=%s\n", URI)
}
req, err := c.NewJSONRequest("POST", URI, data)
if err != nil {
return nil, err
}
if debug {
fmt.Printf("DEBUG: POST req=%v decoded=%v\n", req, decoded)
}
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Post",
"(",
"URI",
"string",
",",
"data",
"interface",
"{",
"}",
",",
"decoded",
"interface",
"{",
"}",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"if",
"debug",
"{",
"fmt",
".",
"Printf... | // Post performs a Post request request to gandi Live DNS api
// - with data encoded as JSON if a not null data pointer is provided
// - decodes the returned data if a not null decoded pointer is provided
// - ensures the status code is an HTTP accepted | [
"Post",
"performs",
"a",
"Post",
"request",
"request",
"to",
"gandi",
"Live",
"DNS",
"api",
"-",
"with",
"data",
"encoded",
"as",
"JSON",
"if",
"a",
"not",
"null",
"data",
"pointer",
"is",
"provided",
"-",
"decodes",
"the",
"returned",
"data",
"if",
"a",... | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/client/client.go#L159-L178 |
145,779 | prasmussen/gandi-api | client/client.go | Put | func (c *Client) Put(URI string, data interface{}, decoded interface{}) (*http.Response, error) {
req, err := c.NewJSONRequest("PUT", URI, data)
if err != nil {
return nil, err
}
return c.DoRest(req, decoded)
} | go | func (c *Client) Put(URI string, data interface{}, decoded interface{}) (*http.Response, error) {
req, err := c.NewJSONRequest("PUT", URI, data)
if err != nil {
return nil, err
}
return c.DoRest(req, decoded)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Put",
"(",
"URI",
"string",
",",
"data",
"interface",
"{",
"}",
",",
"decoded",
"interface",
"{",
"}",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"c",
".",
"Ne... | // Put performs a Put request to gandi Live DNS api
// - with data encoded as JSON if a not null data pointer is provided
// - decodes the returned data if a not null decoded pointer is provided | [
"Put",
"performs",
"a",
"Put",
"request",
"to",
"gandi",
"Live",
"DNS",
"api",
"-",
"with",
"data",
"encoded",
"as",
"JSON",
"if",
"a",
"not",
"null",
"data",
"pointer",
"is",
"provided",
"-",
"decodes",
"the",
"returned",
"data",
"if",
"a",
"not",
"nu... | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/client/client.go#L183-L189 |
145,780 | prasmussen/gandi-api | client/client.go | Patch | func (c *Client) Patch(URI string, data interface{}, decoded interface{}) (*http.Response, error) {
req, err := c.NewJSONRequest("PATCH", URI, data)
if err != nil {
return nil, err
}
resp, err := c.DoRest(req, decoded)
if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusAccepted {
return nil... | go | func (c *Client) Patch(URI string, data interface{}, decoded interface{}) (*http.Response, error) {
req, err := c.NewJSONRequest("PATCH", URI, data)
if err != nil {
return nil, err
}
resp, err := c.DoRest(req, decoded)
if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusAccepted {
return nil... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Patch",
"(",
"URI",
"string",
",",
"data",
"interface",
"{",
"}",
",",
"decoded",
"interface",
"{",
"}",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"c",
".",
"... | // Patch performs a Patch request to gandi Live DNS api
// - with data encoded as JSON if a not null data pointer is provided
// - decodes the returned data if a not null decoded pointer is provided
// - ensures the status code is an HTTP accepted | [
"Patch",
"performs",
"a",
"Patch",
"request",
"to",
"gandi",
"Live",
"DNS",
"api",
"-",
"with",
"data",
"encoded",
"as",
"JSON",
"if",
"a",
"not",
"null",
"data",
"pointer",
"is",
"provided",
"-",
"decodes",
"the",
"returned",
"data",
"if",
"a",
"not",
... | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/client/client.go#L195-L208 |
145,781 | prasmussen/gandi-api | operation/operation.go | Count | func (self *Operation) Count() (int64, error) {
var result int64
// params := Params{Params: []interface{}{self.Key}}
params := []interface{}{self.Key}
if err := self.Call("operation.count", params, &result); err != nil {
return -1, err
}
return result, nil
} | go | func (self *Operation) Count() (int64, error) {
var result int64
// params := Params{Params: []interface{}{self.Key}}
params := []interface{}{self.Key}
if err := self.Call("operation.count", params, &result); err != nil {
return -1, err
}
return result, nil
} | [
"func",
"(",
"self",
"*",
"Operation",
")",
"Count",
"(",
")",
"(",
"int64",
",",
"error",
")",
"{",
"var",
"result",
"int64",
"\n",
"// params := Params{Params: []interface{}{self.Key}}",
"params",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"self",
".",
... | // Count operations created by this contact | [
"Count",
"operations",
"created",
"by",
"this",
"contact"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/operation/operation.go#L14-L22 |
145,782 | prasmussen/gandi-api | operation/operation.go | Info | func (self *Operation) Info(id int64) (*OperationInfo, error) {
var res map[string]interface{}
// params := Params{Params: []interface{}{self.Key, id}}
params := []interface{}{self.Key, id}
if err := self.Call("operation.info", params, &res); err != nil {
return nil, err
}
return ToOperationInfo(res), nil
} | go | func (self *Operation) Info(id int64) (*OperationInfo, error) {
var res map[string]interface{}
// params := Params{Params: []interface{}{self.Key, id}}
params := []interface{}{self.Key, id}
if err := self.Call("operation.info", params, &res); err != nil {
return nil, err
}
return ToOperationInfo(res), nil
} | [
"func",
"(",
"self",
"*",
"Operation",
")",
"Info",
"(",
"id",
"int64",
")",
"(",
"*",
"OperationInfo",
",",
"error",
")",
"{",
"var",
"res",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n",
"// params := Params{Params: []interface{}{self.Key, id}}",
... | // Get operation information | [
"Get",
"operation",
"information"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/operation/operation.go#L25-L33 |
145,783 | prasmussen/gandi-api | operation/operation.go | Cancel | func (self *Operation) Cancel(id int64) (bool, error) {
var res bool
// params := Params{Params: []interface{}{self.Key, id}}
params := []interface{}{self.Key, id}
if err := self.Call("operation.cancel", params, &res); err != nil {
return false, err
}
return res, nil
} | go | func (self *Operation) Cancel(id int64) (bool, error) {
var res bool
// params := Params{Params: []interface{}{self.Key, id}}
params := []interface{}{self.Key, id}
if err := self.Call("operation.cancel", params, &res); err != nil {
return false, err
}
return res, nil
} | [
"func",
"(",
"self",
"*",
"Operation",
")",
"Cancel",
"(",
"id",
"int64",
")",
"(",
"bool",
",",
"error",
")",
"{",
"var",
"res",
"bool",
"\n",
"// params := Params{Params: []interface{}{self.Key, id}}",
"params",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
... | // Cancel an operation | [
"Cancel",
"an",
"operation"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/operation/operation.go#L36-L44 |
145,784 | prasmussen/gandi-api | operation/operation.go | List | func (self *Operation) List() ([]*OperationInfo, error) {
var res []interface{}
// params := Params{Params: []interface{}{self.Key}}
params := []interface{}{self.Key}
if err := self.Call("operation.list", params, &res); err != nil {
return nil, err
}
operations := make([]*OperationInfo, len(res), len(res))
fo... | go | func (self *Operation) List() ([]*OperationInfo, error) {
var res []interface{}
// params := Params{Params: []interface{}{self.Key}}
params := []interface{}{self.Key}
if err := self.Call("operation.list", params, &res); err != nil {
return nil, err
}
operations := make([]*OperationInfo, len(res), len(res))
fo... | [
"func",
"(",
"self",
"*",
"Operation",
")",
"List",
"(",
")",
"(",
"[",
"]",
"*",
"OperationInfo",
",",
"error",
")",
"{",
"var",
"res",
"[",
"]",
"interface",
"{",
"}",
"\n",
"// params := Params{Params: []interface{}{self.Key}}",
"params",
":=",
"[",
"]"... | // List operations created by this contact | [
"List",
"operations",
"created",
"by",
"this",
"contact"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/operation/operation.go#L47-L60 |
145,785 | prasmussen/gandi-api | domain/zone/version/version.go | Count | func (self *Version) Count(zoneId int64) (int64, error) {
var result int64
params := []interface{}{self.Key, zoneId}
if err := self.Call("domain.zone.version.count", params, &result); err != nil {
return -1, err
}
return result, nil
} | go | func (self *Version) Count(zoneId int64) (int64, error) {
var result int64
params := []interface{}{self.Key, zoneId}
if err := self.Call("domain.zone.version.count", params, &result); err != nil {
return -1, err
}
return result, nil
} | [
"func",
"(",
"self",
"*",
"Version",
")",
"Count",
"(",
"zoneId",
"int64",
")",
"(",
"int64",
",",
"error",
")",
"{",
"var",
"result",
"int64",
"\n",
"params",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"self",
".",
"Key",
",",
"zoneId",
"}",
"\... | // Count this zone versions | [
"Count",
"this",
"zone",
"versions"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/domain/zone/version/version.go#L14-L21 |
145,786 | prasmussen/gandi-api | domain/zone/version/version.go | List | func (self *Version) List(zoneId int64) ([]*VersionInfo, error) {
var res []interface{}
params := []interface{}{self.Key, zoneId}
if err := self.Call("domain.zone.version.list", params, &res); err != nil {
return nil, err
}
versions := make([]*VersionInfo, 0)
for _, r := range res {
version := ToVersionInfo(... | go | func (self *Version) List(zoneId int64) ([]*VersionInfo, error) {
var res []interface{}
params := []interface{}{self.Key, zoneId}
if err := self.Call("domain.zone.version.list", params, &res); err != nil {
return nil, err
}
versions := make([]*VersionInfo, 0)
for _, r := range res {
version := ToVersionInfo(... | [
"func",
"(",
"self",
"*",
"Version",
")",
"List",
"(",
"zoneId",
"int64",
")",
"(",
"[",
"]",
"*",
"VersionInfo",
",",
"error",
")",
"{",
"var",
"res",
"[",
"]",
"interface",
"{",
"}",
"\n",
"params",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
... | // List this zone versions, with their creation date | [
"List",
"this",
"zone",
"versions",
"with",
"their",
"creation",
"date"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/domain/zone/version/version.go#L24-L37 |
145,787 | prasmussen/gandi-api | domain/zone/version/version.go | Delete | func (self *Version) Delete(zoneId, version int64) (bool, error) {
var res bool
params := []interface{}{self.Key, zoneId, version}
if err := self.Call("domain.zone.version.delete", params, &res); err != nil {
return false, err
}
return res, nil
} | go | func (self *Version) Delete(zoneId, version int64) (bool, error) {
var res bool
params := []interface{}{self.Key, zoneId, version}
if err := self.Call("domain.zone.version.delete", params, &res); err != nil {
return false, err
}
return res, nil
} | [
"func",
"(",
"self",
"*",
"Version",
")",
"Delete",
"(",
"zoneId",
",",
"version",
"int64",
")",
"(",
"bool",
",",
"error",
")",
"{",
"var",
"res",
"bool",
"\n",
"params",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"self",
".",
"Key",
",",
"zone... | // Delete a specific version | [
"Delete",
"a",
"specific",
"version"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/domain/zone/version/version.go#L51-L58 |
145,788 | prasmussen/gandi-api | live_dns/zone/zone.go | InfoByUUID | func (z *Zone) InfoByUUID(uuid uuid.UUID) (info *Info, err error) {
_, err = z.Get(fmt.Sprintf("/zones/%s", uuid), &info)
if debug {
fmt.Printf("DEBUG: InfoByUUID returned SharingID=%v domain=%v\n", info.SharingID, info.Name)
}
return
} | go | func (z *Zone) InfoByUUID(uuid uuid.UUID) (info *Info, err error) {
_, err = z.Get(fmt.Sprintf("/zones/%s", uuid), &info)
if debug {
fmt.Printf("DEBUG: InfoByUUID returned SharingID=%v domain=%v\n", info.SharingID, info.Name)
}
return
} | [
"func",
"(",
"z",
"*",
"Zone",
")",
"InfoByUUID",
"(",
"uuid",
"uuid",
".",
"UUID",
")",
"(",
"info",
"*",
"Info",
",",
"err",
"error",
")",
"{",
"_",
",",
"err",
"=",
"z",
".",
"Get",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"uuid",... | // InfoByUUID Gets zone information from its UUID | [
"InfoByUUID",
"Gets",
"zone",
"information",
"from",
"its",
"UUID"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/live_dns/zone/zone.go#L32-L38 |
145,789 | prasmussen/gandi-api | live_dns/zone/zone.go | Info | func (z *Zone) Info(zoneInfo Info) (info *Info, err error) {
if zoneInfo.UUID == nil {
return nil, fmt.Errorf("can not get zone info %s without an id", zoneInfo.Name)
}
return z.InfoByUUID(*zoneInfo.UUID)
} | go | func (z *Zone) Info(zoneInfo Info) (info *Info, err error) {
if zoneInfo.UUID == nil {
return nil, fmt.Errorf("can not get zone info %s without an id", zoneInfo.Name)
}
return z.InfoByUUID(*zoneInfo.UUID)
} | [
"func",
"(",
"z",
"*",
"Zone",
")",
"Info",
"(",
"zoneInfo",
"Info",
")",
"(",
"info",
"*",
"Info",
",",
"err",
"error",
")",
"{",
"if",
"zoneInfo",
".",
"UUID",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
","... | // Info Gets zone information | [
"Info",
"Gets",
"zone",
"information"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/live_dns/zone/zone.go#L41-L46 |
145,790 | prasmussen/gandi-api | live_dns/zone/zone.go | Create | func (z *Zone) Create(zoneInfo Info) (status *CreateStatus, err error) {
if debug {
fmt.Printf("DEBUG: Create WILL SET SharingID=%v domain=%v\n", zoneInfo.SharingID, zoneInfo.Name)
}
_, err = z.Post(fmt.Sprintf("/zones?sharing_id=%s", zoneInfo.SharingID), zoneInfo, &status)
return
} | go | func (z *Zone) Create(zoneInfo Info) (status *CreateStatus, err error) {
if debug {
fmt.Printf("DEBUG: Create WILL SET SharingID=%v domain=%v\n", zoneInfo.SharingID, zoneInfo.Name)
}
_, err = z.Post(fmt.Sprintf("/zones?sharing_id=%s", zoneInfo.SharingID), zoneInfo, &status)
return
} | [
"func",
"(",
"z",
"*",
"Zone",
")",
"Create",
"(",
"zoneInfo",
"Info",
")",
"(",
"status",
"*",
"CreateStatus",
",",
"err",
"error",
")",
"{",
"if",
"debug",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"zoneInfo",
".",
"SharingID",
",",... | // Create creates a new zone | [
"Create",
"creates",
"a",
"new",
"zone"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/live_dns/zone/zone.go#L49-L55 |
145,791 | prasmussen/gandi-api | live_dns/zone/zone.go | Update | func (z *Zone) Update(zoneInfo Info) (status *Status, err error) {
if zoneInfo.UUID == nil {
return nil, fmt.Errorf("can not update zone %s without an id", zoneInfo.Name)
}
_, err = z.Patch(fmt.Sprintf("/zones/%s", zoneInfo.UUID), zoneInfo, &status)
return
} | go | func (z *Zone) Update(zoneInfo Info) (status *Status, err error) {
if zoneInfo.UUID == nil {
return nil, fmt.Errorf("can not update zone %s without an id", zoneInfo.Name)
}
_, err = z.Patch(fmt.Sprintf("/zones/%s", zoneInfo.UUID), zoneInfo, &status)
return
} | [
"func",
"(",
"z",
"*",
"Zone",
")",
"Update",
"(",
"zoneInfo",
"Info",
")",
"(",
"status",
"*",
"Status",
",",
"err",
"error",
")",
"{",
"if",
"zoneInfo",
".",
"UUID",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",... | // Update updates an existing zone | [
"Update",
"updates",
"an",
"existing",
"zone"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/live_dns/zone/zone.go#L58-L64 |
145,792 | prasmussen/gandi-api | live_dns/zone/zone.go | Delete | func (z *Zone) Delete(zoneInfo Info) (err error) {
if zoneInfo.UUID == nil {
return fmt.Errorf("can not update zone %s without an id", zoneInfo.Name)
}
_, err = z.Client.Delete(fmt.Sprintf("/zones/%s", zoneInfo.UUID), nil)
return
} | go | func (z *Zone) Delete(zoneInfo Info) (err error) {
if zoneInfo.UUID == nil {
return fmt.Errorf("can not update zone %s without an id", zoneInfo.Name)
}
_, err = z.Client.Delete(fmt.Sprintf("/zones/%s", zoneInfo.UUID), nil)
return
} | [
"func",
"(",
"z",
"*",
"Zone",
")",
"Delete",
"(",
"zoneInfo",
"Info",
")",
"(",
"err",
"error",
")",
"{",
"if",
"zoneInfo",
".",
"UUID",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"zoneInfo",
".",
"Name",
")",
"\n",
... | // Delete Deletes an existing zone | [
"Delete",
"Deletes",
"an",
"existing",
"zone"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/live_dns/zone/zone.go#L67-L73 |
145,793 | prasmussen/gandi-api | live_dns/zone/zone.go | Domains | func (z *Zone) Domains(zoneInfo Info) (domains []*domain.InfoBase, err error) {
if zoneInfo.UUID == nil {
return nil, fmt.Errorf("can not get domains on a zone %s without an id", zoneInfo.Name)
}
_, err = z.Get(fmt.Sprintf("/zones/%s/domains", zoneInfo.UUID), &domains)
return
} | go | func (z *Zone) Domains(zoneInfo Info) (domains []*domain.InfoBase, err error) {
if zoneInfo.UUID == nil {
return nil, fmt.Errorf("can not get domains on a zone %s without an id", zoneInfo.Name)
}
_, err = z.Get(fmt.Sprintf("/zones/%s/domains", zoneInfo.UUID), &domains)
return
} | [
"func",
"(",
"z",
"*",
"Zone",
")",
"Domains",
"(",
"zoneInfo",
"Info",
")",
"(",
"domains",
"[",
"]",
"*",
"domain",
".",
"InfoBase",
",",
"err",
"error",
")",
"{",
"if",
"zoneInfo",
".",
"UUID",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".... | // Domains lists all domains using a zone | [
"Domains",
"lists",
"all",
"domains",
"using",
"a",
"zone"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/live_dns/zone/zone.go#L76-L83 |
145,794 | prasmussen/gandi-api | live_dns/zone/zone.go | Records | func (z *Zone) Records(zoneInfo Info) record.Manager {
return record.New(z.Client, fmt.Sprintf("/zones/%s", zoneInfo.UUID))
} | go | func (z *Zone) Records(zoneInfo Info) record.Manager {
return record.New(z.Client, fmt.Sprintf("/zones/%s", zoneInfo.UUID))
} | [
"func",
"(",
"z",
"*",
"Zone",
")",
"Records",
"(",
"zoneInfo",
"Info",
")",
"record",
".",
"Manager",
"{",
"return",
"record",
".",
"New",
"(",
"z",
".",
"Client",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"zoneInfo",
".",
"UUID",
")",
"... | // Records gets a record client for the current zone | [
"Records",
"gets",
"a",
"record",
"client",
"for",
"the",
"current",
"zone"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/live_dns/zone/zone.go#L98-L100 |
145,795 | prasmussen/gandi-api | domain/zone/record/record.go | List | func (self *Record) List(zoneId, version int64) ([]*RecordInfo, error) {
opts := &struct {
Page int `xmlrpc:"page"`
}{0}
const perPage = 100
params := []interface{}{self.Key, zoneId, version, opts}
records := make([]*RecordInfo, 0)
for {
var res []interface{}
if err := self.Call("domain.zone.record.list", p... | go | func (self *Record) List(zoneId, version int64) ([]*RecordInfo, error) {
opts := &struct {
Page int `xmlrpc:"page"`
}{0}
const perPage = 100
params := []interface{}{self.Key, zoneId, version, opts}
records := make([]*RecordInfo, 0)
for {
var res []interface{}
if err := self.Call("domain.zone.record.list", p... | [
"func",
"(",
"self",
"*",
"Record",
")",
"List",
"(",
"zoneId",
",",
"version",
"int64",
")",
"(",
"[",
"]",
"*",
"RecordInfo",
",",
"error",
")",
"{",
"opts",
":=",
"&",
"struct",
"{",
"Page",
"int",
"`xmlrpc:\"page\"`",
"\n",
"}",
"{",
"0",
"}",
... | // List records of a version of a DNS zone | [
"List",
"records",
"of",
"a",
"version",
"of",
"a",
"DNS",
"zone"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/domain/zone/record/record.go#L26-L48 |
145,796 | prasmussen/gandi-api | domain/zone/record/record.go | Add | func (self *Record) Add(args RecordAdd) (*RecordInfo, error) {
var res map[string]interface{}
createArgs := map[string]interface{}{
"name": args.Name,
"type": args.Type,
"value": args.Value,
"ttl": args.Ttl,
}
params := []interface{}{self.Key, args.Zone, args.Version, createArgs}
if err := self.Call("... | go | func (self *Record) Add(args RecordAdd) (*RecordInfo, error) {
var res map[string]interface{}
createArgs := map[string]interface{}{
"name": args.Name,
"type": args.Type,
"value": args.Value,
"ttl": args.Ttl,
}
params := []interface{}{self.Key, args.Zone, args.Version, createArgs}
if err := self.Call("... | [
"func",
"(",
"self",
"*",
"Record",
")",
"Add",
"(",
"args",
"RecordAdd",
")",
"(",
"*",
"RecordInfo",
",",
"error",
")",
"{",
"var",
"res",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n",
"createArgs",
":=",
"map",
"[",
"string",
"]",
"int... | // Add a new record to zone | [
"Add",
"a",
"new",
"record",
"to",
"zone"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/domain/zone/record/record.go#L51-L65 |
145,797 | prasmussen/gandi-api | domain/zone/record/record.go | SetRecords | func (self *Record) SetRecords(zone_id, version_id int64, args []RecordSet) ([]*RecordInfo, error) {
var res []interface{}
params := []interface{}{self.Key, zone_id, version_id, args}
if err := self.Call("domain.zone.record.set", params, &res); err != nil {
return nil, err
}
records := make([]*RecordInfo, 0)
... | go | func (self *Record) SetRecords(zone_id, version_id int64, args []RecordSet) ([]*RecordInfo, error) {
var res []interface{}
params := []interface{}{self.Key, zone_id, version_id, args}
if err := self.Call("domain.zone.record.set", params, &res); err != nil {
return nil, err
}
records := make([]*RecordInfo, 0)
... | [
"func",
"(",
"self",
"*",
"Record",
")",
"SetRecords",
"(",
"zone_id",
",",
"version_id",
"int64",
",",
"args",
"[",
"]",
"RecordSet",
")",
"(",
"[",
"]",
"*",
"RecordInfo",
",",
"error",
")",
"{",
"var",
"res",
"[",
"]",
"interface",
"{",
"}",
"\n... | // SetRecords replaces the entire zone with new records. | [
"SetRecords",
"replaces",
"the",
"entire",
"zone",
"with",
"new",
"records",
"."
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/domain/zone/record/record.go#L105-L119 |
145,798 | prasmussen/gandi-api | contact/contact.go | Balance | func (self *Contact) Balance() (*BalanceInformation, error) {
var res map[string]interface{}
params := []interface{}{self.Key}
if err := self.Call("contact.balance", params, &res); err != nil {
return nil, err
}
return toBalanceInformation(res), nil
} | go | func (self *Contact) Balance() (*BalanceInformation, error) {
var res map[string]interface{}
params := []interface{}{self.Key}
if err := self.Call("contact.balance", params, &res); err != nil {
return nil, err
}
return toBalanceInformation(res), nil
} | [
"func",
"(",
"self",
"*",
"Contact",
")",
"Balance",
"(",
")",
"(",
"*",
"BalanceInformation",
",",
"error",
")",
"{",
"var",
"res",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n",
"params",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"self... | // Get contact financial balance | [
"Get",
"contact",
"financial",
"balance"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/contact/contact.go#L14-L21 |
145,799 | prasmussen/gandi-api | contact/contact.go | Info | func (self *Contact) Info(handle string) (*ContactInformation, error) {
var res map[string]interface{}
var params []interface{}
if handle == "" {
params = []interface{}{self.Key}
} else {
params = []interface{}{self.Key, handle}
}
if err := self.Call("contact.info", params, &res); err != nil {
return nil, ... | go | func (self *Contact) Info(handle string) (*ContactInformation, error) {
var res map[string]interface{}
var params []interface{}
if handle == "" {
params = []interface{}{self.Key}
} else {
params = []interface{}{self.Key, handle}
}
if err := self.Call("contact.info", params, &res); err != nil {
return nil, ... | [
"func",
"(",
"self",
"*",
"Contact",
")",
"Info",
"(",
"handle",
"string",
")",
"(",
"*",
"ContactInformation",
",",
"error",
")",
"{",
"var",
"res",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n\n",
"var",
"params",
"[",
"]",
"interface",
"{... | // Get contact information | [
"Get",
"contact",
"information"
] | 58d3d42056619bb56e311c115c1c95294b5ec60b | https://github.com/prasmussen/gandi-api/blob/58d3d42056619bb56e311c115c1c95294b5ec60b/contact/contact.go#L24-L37 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.