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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
19,600 | gramework/gramework | router.go | HTTP | func (r *Router) HTTP() *Router {
if r.root != nil {
return r.root.HTTP()
}
r.mu.Lock()
if r.httprouter == nil {
r.httprouter = &Router{
router: newRouter(),
app: r.app,
root: r,
}
}
r.mu.Unlock()
return r.httprouter
} | go | func (r *Router) HTTP() *Router {
if r.root != nil {
return r.root.HTTP()
}
r.mu.Lock()
if r.httprouter == nil {
r.httprouter = &Router{
router: newRouter(),
app: r.app,
root: r,
}
}
r.mu.Unlock()
return r.httprouter
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"HTTP",
"(",
")",
"*",
"Router",
"{",
"if",
"r",
".",
"root",
"!=",
"nil",
"{",
"return",
"r",
".",
"root",
".",
"HTTP",
"(",
")",
"\n",
"}",
"\n",
"r",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"if",
"... | // HTTP router returns a router instance that work only on HTTP requests | [
"HTTP",
"router",
"returns",
"a",
"router",
"instance",
"that",
"work",
"only",
"on",
"HTTP",
"requests"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/router.go#L259-L274 |
19,601 | gramework/gramework | router.go | HTTPS | func (r *Router) HTTPS() *Router {
if r.root != nil {
return r.root.HTTPS()
}
r.mu.Lock()
if r.httpsrouter == nil {
r.httpsrouter = &Router{
router: newRouter(),
app: r.app,
root: r,
}
}
r.mu.Unlock()
return r.httpsrouter
} | go | func (r *Router) HTTPS() *Router {
if r.root != nil {
return r.root.HTTPS()
}
r.mu.Lock()
if r.httpsrouter == nil {
r.httpsrouter = &Router{
router: newRouter(),
app: r.app,
root: r,
}
}
r.mu.Unlock()
return r.httpsrouter
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"HTTPS",
"(",
")",
"*",
"Router",
"{",
"if",
"r",
".",
"root",
"!=",
"nil",
"{",
"return",
"r",
".",
"root",
".",
"HTTPS",
"(",
")",
"\n",
"}",
"\n",
"r",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"if",
... | // HTTPS router returns a router instance that work only on HTTPS requests | [
"HTTPS",
"router",
"returns",
"a",
"router",
"instance",
"that",
"work",
"only",
"on",
"HTTPS",
"requests"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/router.go#L277-L292 |
19,602 | gramework/gramework | internal/gfmt/si.go | Si | func Si(n uint64) string {
suff := siRaw
x := float64(n)
for ; x >= 1024; x = x / 1024 {
suff++
}
return fmt.Sprintf("%.2f%s", x, suff.String())
} | go | func Si(n uint64) string {
suff := siRaw
x := float64(n)
for ; x >= 1024; x = x / 1024 {
suff++
}
return fmt.Sprintf("%.2f%s", x, suff.String())
} | [
"func",
"Si",
"(",
"n",
"uint64",
")",
"string",
"{",
"suff",
":=",
"siRaw",
"\n",
"x",
":=",
"float64",
"(",
"n",
")",
"\n",
"for",
";",
"x",
">=",
"1024",
";",
"x",
"=",
"x",
"/",
"1024",
"{",
"suff",
"++",
"\n",
"}",
"\n\n",
"return",
"fmt... | // Si formats a number in a short si format | [
"Si",
"formats",
"a",
"number",
"in",
"a",
"short",
"si",
"format"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/internal/gfmt/si.go#L6-L14 |
19,603 | gramework/gramework | app_healthcheck.go | HealthHandler | func (app *App) HealthHandler(ctx *Context) {
var m runtime.MemStats
runtime.ReadMemStats(&m)
e := ctx.JSON(m)
_ = e
} | go | func (app *App) HealthHandler(ctx *Context) {
var m runtime.MemStats
runtime.ReadMemStats(&m)
e := ctx.JSON(m)
_ = e
} | [
"func",
"(",
"app",
"*",
"App",
")",
"HealthHandler",
"(",
"ctx",
"*",
"Context",
")",
"{",
"var",
"m",
"runtime",
".",
"MemStats",
"\n",
"runtime",
".",
"ReadMemStats",
"(",
"&",
"m",
")",
"\n\n",
"e",
":=",
"ctx",
".",
"JSON",
"(",
"m",
")",
"\... | // HealthHandler serves info about memory usage | [
"HealthHandler",
"serves",
"info",
"about",
"memory",
"usage"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/app_healthcheck.go#L18-L24 |
19,604 | gramework/gramework | infrastructure/infrastructure_AddServiceServer.go | AddServiceServer | func (i *Infrastructure) AddServiceServer(serviceName string, addr Address) error {
i.Lock.RLock()
if _, ok := i.Services[serviceName]; !ok {
i.Lock.RUnlock()
return ErrServiceNotExists
}
i.Lock.RUnlock()
i.Lock.Lock()
if i.Services[serviceName].Addresses == nil {
i.Services[serviceName].Addresses = make([]... | go | func (i *Infrastructure) AddServiceServer(serviceName string, addr Address) error {
i.Lock.RLock()
if _, ok := i.Services[serviceName]; !ok {
i.Lock.RUnlock()
return ErrServiceNotExists
}
i.Lock.RUnlock()
i.Lock.Lock()
if i.Services[serviceName].Addresses == nil {
i.Services[serviceName].Addresses = make([]... | [
"func",
"(",
"i",
"*",
"Infrastructure",
")",
"AddServiceServer",
"(",
"serviceName",
"string",
",",
"addr",
"Address",
")",
"error",
"{",
"i",
".",
"Lock",
".",
"RLock",
"(",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"i",
".",
"Services",
"[",
"service... | // AddServiceServer registers server to a service in the infrastructure | [
"AddServiceServer",
"registers",
"server",
"to",
"a",
"service",
"in",
"the",
"infrastructure"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/infrastructure/infrastructure_AddServiceServer.go#L13-L28 |
19,605 | gramework/gramework | metrics/metrics.go | Register | func Register(app *gramework.App, serviceName ...string) error {
var m Middleware
name := os.Args[0]
if len(serviceName) > 0 {
name = serviceName[0]
}
hostname, err := os.Hostname()
if err != nil {
return err
}
m.httpReqCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "gramework_http... | go | func Register(app *gramework.App, serviceName ...string) error {
var m Middleware
name := os.Args[0]
if len(serviceName) > 0 {
name = serviceName[0]
}
hostname, err := os.Hostname()
if err != nil {
return err
}
m.httpReqCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "gramework_http... | [
"func",
"Register",
"(",
"app",
"*",
"gramework",
".",
"App",
",",
"serviceName",
"...",
"string",
")",
"error",
"{",
"var",
"m",
"Middleware",
"\n",
"name",
":=",
"os",
".",
"Args",
"[",
"0",
"]",
"\n",
"if",
"len",
"(",
"serviceName",
")",
">",
"... | // Register the middlewares | [
"Register",
"the",
"middlewares"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/metrics/metrics.go#L33-L83 |
19,606 | gramework/gramework | app.go | SetCookieExpire | func (app *App) SetCookieExpire(d time.Duration) {
if d != 0 {
app.cookieExpire = d
}
} | go | func (app *App) SetCookieExpire(d time.Duration) {
if d != 0 {
app.cookieExpire = d
}
} | [
"func",
"(",
"app",
"*",
"App",
")",
"SetCookieExpire",
"(",
"d",
"time",
".",
"Duration",
")",
"{",
"if",
"d",
"!=",
"0",
"{",
"app",
".",
"cookieExpire",
"=",
"d",
"\n",
"}",
"\n",
"}"
] | // SetCookieExpire allows you set cookie expire time | [
"SetCookieExpire",
"allows",
"you",
"set",
"cookie",
"expire",
"time"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/app.go#L31-L35 |
19,607 | gramework/gramework | app.go | SetSanitizerPolicy | func (app *App) SetSanitizerPolicy(newPolicy *bluemonday.Policy) {
if newPolicy != nil {
app.sanitizerPolicy = newPolicy
}
} | go | func (app *App) SetSanitizerPolicy(newPolicy *bluemonday.Policy) {
if newPolicy != nil {
app.sanitizerPolicy = newPolicy
}
} | [
"func",
"(",
"app",
"*",
"App",
")",
"SetSanitizerPolicy",
"(",
"newPolicy",
"*",
"bluemonday",
".",
"Policy",
")",
"{",
"if",
"newPolicy",
"!=",
"nil",
"{",
"app",
".",
"sanitizerPolicy",
"=",
"newPolicy",
"\n",
"}",
"\n",
"}"
] | // SetSanitizerPolicy updates app's sanitizer policy to a new one, if newPolicy is not nil | [
"SetSanitizerPolicy",
"updates",
"app",
"s",
"sanitizer",
"policy",
"to",
"a",
"new",
"one",
"if",
"newPolicy",
"is",
"not",
"nil"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/app.go#L49-L53 |
19,608 | gramework/gramework | app_shutdown.go | Shutdown | func (app *App) Shutdown() (err error) {
app.runningServersMu.Lock()
// this is not a hot path, we can freely use defer here
defer app.runningServersMu.Unlock()
newRunningList := []runningServerInfo{}
for _, info := range app.runningServers {
app.internalLog.WithField("bind", info.bind).Warn("shutting down serv... | go | func (app *App) Shutdown() (err error) {
app.runningServersMu.Lock()
// this is not a hot path, we can freely use defer here
defer app.runningServersMu.Unlock()
newRunningList := []runningServerInfo{}
for _, info := range app.runningServers {
app.internalLog.WithField("bind", info.bind).Warn("shutting down serv... | [
"func",
"(",
"app",
"*",
"App",
")",
"Shutdown",
"(",
")",
"(",
"err",
"error",
")",
"{",
"app",
".",
"runningServersMu",
".",
"Lock",
"(",
")",
"\n",
"// this is not a hot path, we can freely use defer here",
"defer",
"app",
".",
"runningServersMu",
".",
"Unl... | // Shutdown gracefully shuts down application servers | [
"Shutdown",
"gracefully",
"shuts",
"down",
"application",
"servers"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/app_shutdown.go#L4-L28 |
19,609 | gramework/gramework | behind/akamai/akamai.go | New | func New(opts ...Option) *Unwrapper {
a := &Unwrapper{
ipHeader: DefaultAkamaiIPHeader,
}
for _, opt := range opts {
opt(a)
}
return a
} | go | func New(opts ...Option) *Unwrapper {
a := &Unwrapper{
ipHeader: DefaultAkamaiIPHeader,
}
for _, opt := range opts {
opt(a)
}
return a
} | [
"func",
"New",
"(",
"opts",
"...",
"Option",
")",
"*",
"Unwrapper",
"{",
"a",
":=",
"&",
"Unwrapper",
"{",
"ipHeader",
":",
"DefaultAkamaiIPHeader",
",",
"}",
"\n\n",
"for",
"_",
",",
"opt",
":=",
"range",
"opts",
"{",
"opt",
"(",
"a",
")",
"\n",
"... | // New creates an unwrapper, optimized for Akamai network | [
"New",
"creates",
"an",
"unwrapper",
"optimized",
"for",
"Akamai",
"network"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/behind/akamai/akamai.go#L62-L72 |
19,610 | gramework/gramework | tolower_go112.go | toLower | func toLower(s string) string {
isASCII, hasUpper := true, false
for i := 0; i < len(s); i++ {
c := s[i]
if c >= utf8.RuneSelf {
isASCII = false
break
}
hasUpper = hasUpper || (c >= 'A' && c <= 'Z')
}
if isASCII { // optimize for ASCII-only strings.
if !hasUpper {
return s
}
var b strings.Bu... | go | func toLower(s string) string {
isASCII, hasUpper := true, false
for i := 0; i < len(s); i++ {
c := s[i]
if c >= utf8.RuneSelf {
isASCII = false
break
}
hasUpper = hasUpper || (c >= 'A' && c <= 'Z')
}
if isASCII { // optimize for ASCII-only strings.
if !hasUpper {
return s
}
var b strings.Bu... | [
"func",
"toLower",
"(",
"s",
"string",
")",
"string",
"{",
"isASCII",
",",
"hasUpper",
":=",
"true",
",",
"false",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"s",
")",
";",
"i",
"++",
"{",
"c",
":=",
"s",
"[",
"i",
"]",
"\n",
"... | // toLower returns a copy of the string s with all Unicode letters mapped to their lower case. | [
"toLower",
"returns",
"a",
"copy",
"of",
"the",
"string",
"s",
"with",
"all",
"Unicode",
"letters",
"mapped",
"to",
"their",
"lower",
"case",
"."
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/tolower_go112.go#L16-L43 |
19,611 | gramework/gramework | tolower_go112.go | stringsMap | func stringsMap(mapping func(rune) rune, s string) string {
// In the worst case, the string can grow when mapped, making
// things unpleasant. But it's so rare we barge in assuming it's
// fine. It could also shrink but that falls out naturally.
// The output buffer b is initialized on demand, the first
// time ... | go | func stringsMap(mapping func(rune) rune, s string) string {
// In the worst case, the string can grow when mapped, making
// things unpleasant. But it's so rare we barge in assuming it's
// fine. It could also shrink but that falls out naturally.
// The output buffer b is initialized on demand, the first
// time ... | [
"func",
"stringsMap",
"(",
"mapping",
"func",
"(",
"rune",
")",
"rune",
",",
"s",
"string",
")",
"string",
"{",
"// In the worst case, the string can grow when mapped, making",
"// things unpleasant. But it's so rare we barge in assuming it's",
"// fine. It could also shrink but th... | // Map returns a copy of the string s with all its characters modified
// according to the mapping function. If mapping returns a negative value, the character is
// dropped from the string with no replacement. | [
"Map",
"returns",
"a",
"copy",
"of",
"the",
"string",
"s",
"with",
"all",
"its",
"characters",
"modified",
"according",
"to",
"the",
"mapping",
"function",
".",
"If",
"mapping",
"returns",
"a",
"negative",
"value",
"the",
"character",
"is",
"dropped",
"from"... | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/tolower_go112.go#L48-L105 |
19,612 | gramework/gramework | infrastructure/infrastructure_RegisterService.go | RegisterService | func (i *Infrastructure) RegisterService(name string, s Service) error {
i.Lock.RLock()
if _, ok := i.Services[name]; ok {
i.Lock.RUnlock()
return ErrServiceExists
}
i.Lock.RUnlock()
i.Lock.Lock()
if s.Name == "" {
s.Name = name
}
i.Services[name] = &s
i.Lock.Unlock()
return nil
} | go | func (i *Infrastructure) RegisterService(name string, s Service) error {
i.Lock.RLock()
if _, ok := i.Services[name]; ok {
i.Lock.RUnlock()
return ErrServiceExists
}
i.Lock.RUnlock()
i.Lock.Lock()
if s.Name == "" {
s.Name = name
}
i.Services[name] = &s
i.Lock.Unlock()
return nil
} | [
"func",
"(",
"i",
"*",
"Infrastructure",
")",
"RegisterService",
"(",
"name",
"string",
",",
"s",
"Service",
")",
"error",
"{",
"i",
".",
"Lock",
".",
"RLock",
"(",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"i",
".",
"Services",
"[",
"name",
"]",
";... | // RegisterService in the infrastructure | [
"RegisterService",
"in",
"the",
"infrastructure"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/infrastructure/infrastructure_RegisterService.go#L13-L28 |
19,613 | gramework/gramework | infrastructure/infrastructure_RegisterService.go | MergeService | func (i *Infrastructure) MergeService(name string, s Service) {
i.Lock.Lock()
if _, ok := i.Services[name]; ok {
i.Services[name].Addresses = append(i.Services[name].Addresses, s.Addresses...)
i.Lock.Unlock()
return
}
i.Services[name] = &s
i.Lock.Unlock()
} | go | func (i *Infrastructure) MergeService(name string, s Service) {
i.Lock.Lock()
if _, ok := i.Services[name]; ok {
i.Services[name].Addresses = append(i.Services[name].Addresses, s.Addresses...)
i.Lock.Unlock()
return
}
i.Services[name] = &s
i.Lock.Unlock()
} | [
"func",
"(",
"i",
"*",
"Infrastructure",
")",
"MergeService",
"(",
"name",
"string",
",",
"s",
"Service",
")",
"{",
"i",
".",
"Lock",
".",
"Lock",
"(",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"i",
".",
"Services",
"[",
"name",
"]",
";",
"ok",
"{... | // MergeService in the infrastructure | [
"MergeService",
"in",
"the",
"infrastructure"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/infrastructure/infrastructure_RegisterService.go#L53-L62 |
19,614 | gramework/gramework | log.go | SetEnv | func SetEnv(e Environment) {
if e != DEV && e != STAGE && e != PROD {
internalLog.Warn("could not set unknown environment value, ignoring")
return
}
if e != GetEnv() {
internalLog.
WithField("prevEnv", GetEnv()).
WithField("newEnv", e).
Warn("Setting a new environment")
}
if e == PROD {
Logger.Lev... | go | func SetEnv(e Environment) {
if e != DEV && e != STAGE && e != PROD {
internalLog.Warn("could not set unknown environment value, ignoring")
return
}
if e != GetEnv() {
internalLog.
WithField("prevEnv", GetEnv()).
WithField("newEnv", e).
Warn("Setting a new environment")
}
if e == PROD {
Logger.Lev... | [
"func",
"SetEnv",
"(",
"e",
"Environment",
")",
"{",
"if",
"e",
"!=",
"DEV",
"&&",
"e",
"!=",
"STAGE",
"&&",
"e",
"!=",
"PROD",
"{",
"internalLog",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"e",
"!=",
"GetEnv",
"... | // SetEnv sets gramework's environment | [
"SetEnv",
"sets",
"gramework",
"s",
"environment"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/log.go#L81-L100 |
19,615 | gramework/gramework | app_listenAndServeAutoTLS.go | ListenAndServeAutoTLS | func (app *App) ListenAndServeAutoTLS(addr string, cachePath ...string) error {
if len(app.TLSEmails) == 0 {
return ErrTLSNoEmails
}
addr, err := normalizeTLSAddr(addr)
if err != nil {
app.internalLog.Errorf("Bad address %q: %s", addr, err)
}
ln, err := net.Listen("tcp", addr)
if err != nil {
app.interna... | go | func (app *App) ListenAndServeAutoTLS(addr string, cachePath ...string) error {
if len(app.TLSEmails) == 0 {
return ErrTLSNoEmails
}
addr, err := normalizeTLSAddr(addr)
if err != nil {
app.internalLog.Errorf("Bad address %q: %s", addr, err)
}
ln, err := net.Listen("tcp", addr)
if err != nil {
app.interna... | [
"func",
"(",
"app",
"*",
"App",
")",
"ListenAndServeAutoTLS",
"(",
"addr",
"string",
",",
"cachePath",
"...",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"app",
".",
"TLSEmails",
")",
"==",
"0",
"{",
"return",
"ErrTLSNoEmails",
"\n",
"}",
"\n\n",
"a... | // ListenAndServeAutoTLS serves TLS requests | [
"ListenAndServeAutoTLS",
"serves",
"TLS",
"requests"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/app_listenAndServeAutoTLS.go#L41-L106 |
19,616 | gramework/gramework | x/sqlgen/create_table.go | Column | func (tb *CreateTableBuilder) Column(name string) *ColumnBuilder {
return &ColumnBuilder{
tableBuilder: tb,
name: name,
}
} | go | func (tb *CreateTableBuilder) Column(name string) *ColumnBuilder {
return &ColumnBuilder{
tableBuilder: tb,
name: name,
}
} | [
"func",
"(",
"tb",
"*",
"CreateTableBuilder",
")",
"Column",
"(",
"name",
"string",
")",
"*",
"ColumnBuilder",
"{",
"return",
"&",
"ColumnBuilder",
"{",
"tableBuilder",
":",
"tb",
",",
"name",
":",
"name",
",",
"}",
"\n",
"}"
] | // Column initialize a column builder
// that requires you to choose a type
// before you can Build the statement | [
"Column",
"initialize",
"a",
"column",
"builder",
"that",
"requires",
"you",
"to",
"choose",
"a",
"type",
"before",
"you",
"can",
"Build",
"the",
"statement"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/x/sqlgen/create_table.go#L11-L16 |
19,617 | gramework/gramework | x/sqlgen/create_table.go | appendColumn | func (tb *CreateTableBuilder) appendColumn(c *tableColumn) *CreateTableBuilder {
tb.columns = append(tb.columns, *c)
return tb
} | go | func (tb *CreateTableBuilder) appendColumn(c *tableColumn) *CreateTableBuilder {
tb.columns = append(tb.columns, *c)
return tb
} | [
"func",
"(",
"tb",
"*",
"CreateTableBuilder",
")",
"appendColumn",
"(",
"c",
"*",
"tableColumn",
")",
"*",
"CreateTableBuilder",
"{",
"tb",
".",
"columns",
"=",
"append",
"(",
"tb",
".",
"columns",
",",
"*",
"c",
")",
"\n",
"return",
"tb",
"\n",
"}"
] | // appendColumn to the table column list | [
"appendColumn",
"to",
"the",
"table",
"column",
"list"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/x/sqlgen/create_table.go#L19-L22 |
19,618 | gramework/gramework | x/client/new.go | New | func New(config Config) *Instance {
client := &Instance{
conf: &config,
clients: make(map[string]*fasthttp.HostClient),
clientsMu: new(sync.RWMutex),
balancer: newRangeBalancer(),
}
return client
} | go | func New(config Config) *Instance {
client := &Instance{
conf: &config,
clients: make(map[string]*fasthttp.HostClient),
clientsMu: new(sync.RWMutex),
balancer: newRangeBalancer(),
}
return client
} | [
"func",
"New",
"(",
"config",
"Config",
")",
"*",
"Instance",
"{",
"client",
":=",
"&",
"Instance",
"{",
"conf",
":",
"&",
"config",
",",
"clients",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"fasthttp",
".",
"HostClient",
")",
",",
"clientsMu... | // New API client instance | [
"New",
"API",
"client",
"instance"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/x/client/new.go#L20-L29 |
19,619 | gramework/gramework | grypto/providers/scrypt/scrypt_provider.go | Equals | func (p *scryptParams) Equals(p1 *scryptParams) bool {
return p.keyLen == p1.keyLen &&
p.n == p1.n &&
p.r == p1.r &&
p.p == p1.p &&
p.saltLen == p1.saltLen
} | go | func (p *scryptParams) Equals(p1 *scryptParams) bool {
return p.keyLen == p1.keyLen &&
p.n == p1.n &&
p.r == p1.r &&
p.p == p1.p &&
p.saltLen == p1.saltLen
} | [
"func",
"(",
"p",
"*",
"scryptParams",
")",
"Equals",
"(",
"p1",
"*",
"scryptParams",
")",
"bool",
"{",
"return",
"p",
".",
"keyLen",
"==",
"p1",
".",
"keyLen",
"&&",
"p",
".",
"n",
"==",
"p1",
".",
"n",
"&&",
"p",
".",
"r",
"==",
"p1",
".",
... | // Equals returns true if params p equals to params p1 | [
"Equals",
"returns",
"true",
"if",
"params",
"p",
"equals",
"to",
"params",
"p1"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/grypto/providers/scrypt/scrypt_provider.go#L50-L56 |
19,620 | gramework/gramework | grypto/providers/scrypt/scrypt_provider.go | String | func (p *scryptParams) String() string {
return fmt.Sprintf(paramsFmt, p.keyLen, p.n, p.r, p.p, p.saltLen)
} | go | func (p *scryptParams) String() string {
return fmt.Sprintf(paramsFmt, p.keyLen, p.n, p.r, p.p, p.saltLen)
} | [
"func",
"(",
"p",
"*",
"scryptParams",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"paramsFmt",
",",
"p",
".",
"keyLen",
",",
"p",
".",
"n",
",",
"p",
".",
"r",
",",
"p",
".",
"p",
",",
"p",
".",
"saltLen",
"... | // String returns params p as a MCF | [
"String",
"returns",
"params",
"p",
"as",
"a",
"MCF"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/grypto/providers/scrypt/scrypt_provider.go#L59-L61 |
19,621 | gramework/gramework | grypto/providers/scrypt/scrypt_provider.go | New | func New() *Provider {
return &Provider{
params: &scryptParams{
keyLen: DefaultKeyLen,
n: DefaultN,
r: DefaultR,
p: DefaultP,
saltLen: DefaultSaltLen,
},
}
} | go | func New() *Provider {
return &Provider{
params: &scryptParams{
keyLen: DefaultKeyLen,
n: DefaultN,
r: DefaultR,
p: DefaultP,
saltLen: DefaultSaltLen,
},
}
} | [
"func",
"New",
"(",
")",
"*",
"Provider",
"{",
"return",
"&",
"Provider",
"{",
"params",
":",
"&",
"scryptParams",
"{",
"keyLen",
":",
"DefaultKeyLen",
",",
"n",
":",
"DefaultN",
",",
"r",
":",
"DefaultR",
",",
"p",
":",
"DefaultP",
",",
"saltLen",
"... | // New returns new scrypt provider | [
"New",
"returns",
"new",
"scrypt",
"provider"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/grypto/providers/scrypt/scrypt_provider.go#L64-L74 |
19,622 | gramework/gramework | grypto/providers/scrypt/scrypt_provider.go | HashString | func (p *Provider) HashString(plaintext string) []byte {
return p.Hash([]byte(plaintext))
} | go | func (p *Provider) HashString(plaintext string) []byte {
return p.Hash([]byte(plaintext))
} | [
"func",
"(",
"p",
"*",
"Provider",
")",
"HashString",
"(",
"plaintext",
"string",
")",
"[",
"]",
"byte",
"{",
"return",
"p",
".",
"Hash",
"(",
"[",
"]",
"byte",
"(",
"plaintext",
")",
")",
"\n",
"}"
] | // HashString returns scrypt hash of plaintext | [
"HashString",
"returns",
"scrypt",
"hash",
"of",
"plaintext"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/grypto/providers/scrypt/scrypt_provider.go#L107-L109 |
19,623 | gramework/gramework | context_writers.go | Encode | func (ctx *Context) Encode(v interface{}) (string, error) {
accept := ctx.Request.Header.Peek(acceptHeader)
accepted := acceptParser.Parse(BytesToString(accept))
sentType, err := accepted.Negotiate(ctypes...)
if err != nil {
return emptyString, err
}
switch sentType {
case jsonCT:
err = ctx.JSON(v)
case x... | go | func (ctx *Context) Encode(v interface{}) (string, error) {
accept := ctx.Request.Header.Peek(acceptHeader)
accepted := acceptParser.Parse(BytesToString(accept))
sentType, err := accepted.Negotiate(ctypes...)
if err != nil {
return emptyString, err
}
switch sentType {
case jsonCT:
err = ctx.JSON(v)
case x... | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"Encode",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"accept",
":=",
"ctx",
".",
"Request",
".",
"Header",
".",
"Peek",
"(",
"acceptHeader",
")",
"\n",
"accepted",
":=",
"ac... | // Encode automatically determines accepted formats
// and choose preferred one | [
"Encode",
"automatically",
"determines",
"accepted",
"formats",
"and",
"choose",
"preferred",
"one"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/context_writers.go#L17-L36 |
19,624 | gramework/gramework | context_writers.go | HTML | func (ctx *Context) HTML(src ...string) *Context {
ctx.SetContentType(htmlCT)
if len(src) > 0 {
_, e := ctx.WriteString(src[0])
_ = e
}
return ctx
} | go | func (ctx *Context) HTML(src ...string) *Context {
ctx.SetContentType(htmlCT)
if len(src) > 0 {
_, e := ctx.WriteString(src[0])
_ = e
}
return ctx
} | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"HTML",
"(",
"src",
"...",
"string",
")",
"*",
"Context",
"{",
"ctx",
".",
"SetContentType",
"(",
"htmlCT",
")",
"\n",
"if",
"len",
"(",
"src",
")",
">",
"0",
"{",
"_",
",",
"e",
":=",
"ctx",
".",
"Write... | // HTML sets HTML content type | [
"HTML",
"sets",
"HTML",
"content",
"type"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/context_writers.go#L73-L80 |
19,625 | gramework/gramework | context_writers.go | CORS | func (ctx *Context) CORS(domains ...string) *Context {
var origins []string
if len(domains) > 0 {
origins = domains
} else if headerOrigin := ctx.Request.Header.Peek(hOrigin); len(headerOrigin) > 0 {
origins = append(origins, string(headerOrigin))
} else {
origins = append(origins, string(ctx.Request.URI().Ho... | go | func (ctx *Context) CORS(domains ...string) *Context {
var origins []string
if len(domains) > 0 {
origins = domains
} else if headerOrigin := ctx.Request.Header.Peek(hOrigin); len(headerOrigin) > 0 {
origins = append(origins, string(headerOrigin))
} else {
origins = append(origins, string(ctx.Request.URI().Ho... | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"CORS",
"(",
"domains",
"...",
"string",
")",
"*",
"Context",
"{",
"var",
"origins",
"[",
"]",
"string",
"\n",
"if",
"len",
"(",
"domains",
")",
">",
"0",
"{",
"origins",
"=",
"domains",
"\n",
"}",
"else",
... | // CORS enables CORS in the current context | [
"CORS",
"enables",
"CORS",
"in",
"the",
"current",
"context"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/context_writers.go#L83-L99 |
19,626 | gramework/gramework | context_writers.go | JSON | func (ctx *Context) JSON(v interface{}) error {
ctx.SetContentType(jsonCT)
b, err := ctx.ToJSON(v)
if err != nil {
return err
}
_, err = ctx.Write(b)
return err
} | go | func (ctx *Context) JSON(v interface{}) error {
ctx.SetContentType(jsonCT)
b, err := ctx.ToJSON(v)
if err != nil {
return err
}
_, err = ctx.Write(b)
return err
} | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"JSON",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"ctx",
".",
"SetContentType",
"(",
"jsonCT",
")",
"\n",
"b",
",",
"err",
":=",
"ctx",
".",
"ToJSON",
"(",
"v",
")",
"\n",
"if",
"err",
"!=",
"n... | // JSON serializes and writes a json-formatted response to user | [
"JSON",
"serializes",
"and",
"writes",
"a",
"json",
"-",
"formatted",
"response",
"to",
"user"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/context_writers.go#L102-L111 |
19,627 | gramework/gramework | context_writers.go | Err500 | func (ctx *Context) Err500(message ...interface{}) *Context {
ctx.SetStatusCode(fasthttp.StatusInternalServerError)
for k := range message {
switch v := message[k].(type) {
case string:
_, err := ctx.WriteString(v)
if err != nil {
ctx.Logger.WithError(err).Error("Err500 serving error")
}
case error... | go | func (ctx *Context) Err500(message ...interface{}) *Context {
ctx.SetStatusCode(fasthttp.StatusInternalServerError)
for k := range message {
switch v := message[k].(type) {
case string:
_, err := ctx.WriteString(v)
if err != nil {
ctx.Logger.WithError(err).Error("Err500 serving error")
}
case error... | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"Err500",
"(",
"message",
"...",
"interface",
"{",
"}",
")",
"*",
"Context",
"{",
"ctx",
".",
"SetStatusCode",
"(",
"fasthttp",
".",
"StatusInternalServerError",
")",
"\n",
"for",
"k",
":=",
"range",
"message",
"{... | // Err500 sets Internal Server Error status | [
"Err500",
"sets",
"Internal",
"Server",
"Error",
"status"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/context_writers.go#L124-L142 |
19,628 | gramework/gramework | context_writers.go | JSONError | func (ctx *Context) JSONError(v interface{}) error {
ctx.Err500()
return ctx.JSON(v)
} | go | func (ctx *Context) JSONError(v interface{}) error {
ctx.Err500()
return ctx.JSON(v)
} | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"JSONError",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"ctx",
".",
"Err500",
"(",
")",
"\n",
"return",
"ctx",
".",
"JSON",
"(",
"v",
")",
"\n",
"}"
] | // JSONError sets Internal Server Error status,
// serializes and writes a json-formatted response to user | [
"JSONError",
"sets",
"Internal",
"Server",
"Error",
"status",
"serializes",
"and",
"writes",
"a",
"json",
"-",
"formatted",
"response",
"to",
"user"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/context_writers.go#L146-L149 |
19,629 | gramework/gramework | grypto/pass.go | PasswordValid | func PasswordValid(hash, password []byte) bool {
p := matchProvider(hash)
if p == nil {
return false
}
return p.Valid(hash, password)
} | go | func PasswordValid(hash, password []byte) bool {
p := matchProvider(hash)
if p == nil {
return false
}
return p.Valid(hash, password)
} | [
"func",
"PasswordValid",
"(",
"hash",
",",
"password",
"[",
"]",
"byte",
")",
"bool",
"{",
"p",
":=",
"matchProvider",
"(",
"hash",
")",
"\n",
"if",
"p",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"p",
".",
"Valid",
"(",
"hash"... | // PasswordValid checks if provided hash | [
"PasswordValid",
"checks",
"if",
"provided",
"hash"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/grypto/pass.go#L60-L66 |
19,630 | gramework/gramework | opts.go | OptAppName | func OptAppName(n string) func(*App) {
return func(app *App) {
assertAppNotNill(app)
app.name = n
}
} | go | func OptAppName(n string) func(*App) {
return func(app *App) {
assertAppNotNill(app)
app.name = n
}
} | [
"func",
"OptAppName",
"(",
"n",
"string",
")",
"func",
"(",
"*",
"App",
")",
"{",
"return",
"func",
"(",
"app",
"*",
"App",
")",
"{",
"assertAppNotNill",
"(",
"app",
")",
"\n",
"app",
".",
"name",
"=",
"n",
"\n",
"}",
"\n",
"}"
] | // OptAppName sets app.name and app.serverBase.Name | [
"OptAppName",
"sets",
"app",
".",
"name",
"and",
"app",
".",
"serverBase",
".",
"Name"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/opts.go#L21-L26 |
19,631 | gramework/gramework | opts.go | OptUseCustomLogger | func OptUseCustomLogger(logger *log.Logger) func(*App) {
return func(app *App) {
assertAppNotNill(app)
app.Logger = logger
}
} | go | func OptUseCustomLogger(logger *log.Logger) func(*App) {
return func(app *App) {
assertAppNotNill(app)
app.Logger = logger
}
} | [
"func",
"OptUseCustomLogger",
"(",
"logger",
"*",
"log",
".",
"Logger",
")",
"func",
"(",
"*",
"App",
")",
"{",
"return",
"func",
"(",
"app",
"*",
"App",
")",
"{",
"assertAppNotNill",
"(",
"app",
")",
"\n",
"app",
".",
"Logger",
"=",
"logger",
"\n",
... | // OptUseCustomLogger allows use custom preconfigured Apex logger.
// For exmaple with custom Handler. | [
"OptUseCustomLogger",
"allows",
"use",
"custom",
"preconfigured",
"Apex",
"logger",
".",
"For",
"exmaple",
"with",
"custom",
"Handler",
"."
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/opts.go#L30-L35 |
19,632 | gramework/gramework | opts.go | OptUseServer | func OptUseServer(s *fasthttp.Server) func(*App) {
return func(app *App) {
assertAppNotNill(app)
if s == nil {
panic(errors.New("cannot set nil as app server instance"))
}
app.serverBase = s
app.serverBase.Handler = app.handler()
}
} | go | func OptUseServer(s *fasthttp.Server) func(*App) {
return func(app *App) {
assertAppNotNill(app)
if s == nil {
panic(errors.New("cannot set nil as app server instance"))
}
app.serverBase = s
app.serverBase.Handler = app.handler()
}
} | [
"func",
"OptUseServer",
"(",
"s",
"*",
"fasthttp",
".",
"Server",
")",
"func",
"(",
"*",
"App",
")",
"{",
"return",
"func",
"(",
"app",
"*",
"App",
")",
"{",
"assertAppNotNill",
"(",
"app",
")",
"\n",
"if",
"s",
"==",
"nil",
"{",
"panic",
"(",
"e... | // OptUseServer sets fasthttp.Server instance to use | [
"OptUseServer",
"sets",
"fasthttp",
".",
"Server",
"instance",
"to",
"use"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/opts.go#L38-L47 |
19,633 | gramework/gramework | opts.go | OptMaxRequestBodySize | func OptMaxRequestBodySize(size int) func(*App) {
return func(app *App) {
assertAppNotNill(app)
if app.serverBase == nil {
app.serverBase = newDefaultServerBaseFor(app)
}
app.serverBase.MaxRequestBodySize = size
}
} | go | func OptMaxRequestBodySize(size int) func(*App) {
return func(app *App) {
assertAppNotNill(app)
if app.serverBase == nil {
app.serverBase = newDefaultServerBaseFor(app)
}
app.serverBase.MaxRequestBodySize = size
}
} | [
"func",
"OptMaxRequestBodySize",
"(",
"size",
"int",
")",
"func",
"(",
"*",
"App",
")",
"{",
"return",
"func",
"(",
"app",
"*",
"App",
")",
"{",
"assertAppNotNill",
"(",
"app",
")",
"\n",
"if",
"app",
".",
"serverBase",
"==",
"nil",
"{",
"app",
".",
... | // OptMaxRequestBodySize sets new MaxRequestBodySize in the server used at the execution time.
// All OptUseServer will overwrite this setting 'case OptUseServer replaces the whole server instance
// with a new one. | [
"OptMaxRequestBodySize",
"sets",
"new",
"MaxRequestBodySize",
"in",
"the",
"server",
"used",
"at",
"the",
"execution",
"time",
".",
"All",
"OptUseServer",
"will",
"overwrite",
"this",
"setting",
"case",
"OptUseServer",
"replaces",
"the",
"whole",
"server",
"instance... | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/opts.go#L52-L60 |
19,634 | gramework/gramework | opts.go | OptKeepHijackedConns | func OptKeepHijackedConns(keep bool) func(*App) {
return func(app *App) {
assertAppNotNill(app)
if app.serverBase == nil {
app.serverBase = newDefaultServerBaseFor(app)
}
app.serverBase.KeepHijackedConns = keep
}
} | go | func OptKeepHijackedConns(keep bool) func(*App) {
return func(app *App) {
assertAppNotNill(app)
if app.serverBase == nil {
app.serverBase = newDefaultServerBaseFor(app)
}
app.serverBase.KeepHijackedConns = keep
}
} | [
"func",
"OptKeepHijackedConns",
"(",
"keep",
"bool",
")",
"func",
"(",
"*",
"App",
")",
"{",
"return",
"func",
"(",
"app",
"*",
"App",
")",
"{",
"assertAppNotNill",
"(",
"app",
")",
"\n",
"if",
"app",
".",
"serverBase",
"==",
"nil",
"{",
"app",
".",
... | // OptKeepHijackedConns sets new KeepHijackedConns in the server used at the execution time.
// All OptUseServer will overwrite this setting 'case OptUseServer replaces the whole server instance
// with a new one. | [
"OptKeepHijackedConns",
"sets",
"new",
"KeepHijackedConns",
"in",
"the",
"server",
"used",
"at",
"the",
"execution",
"time",
".",
"All",
"OptUseServer",
"will",
"overwrite",
"this",
"setting",
"case",
"OptUseServer",
"replaces",
"the",
"whole",
"server",
"instance",... | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/opts.go#L65-L73 |
19,635 | gramework/gramework | x/sqlgen/columnBuilder.go | Integer | func (cb *ColumnBuilder) Integer() *CreateTableBuilder {
return cb.tableBuilder.appendColumn(&tableColumn{
name: cb.name,
sqlType: "INTEGER",
})
} | go | func (cb *ColumnBuilder) Integer() *CreateTableBuilder {
return cb.tableBuilder.appendColumn(&tableColumn{
name: cb.name,
sqlType: "INTEGER",
})
} | [
"func",
"(",
"cb",
"*",
"ColumnBuilder",
")",
"Integer",
"(",
")",
"*",
"CreateTableBuilder",
"{",
"return",
"cb",
".",
"tableBuilder",
".",
"appendColumn",
"(",
"&",
"tableColumn",
"{",
"name",
":",
"cb",
".",
"name",
",",
"sqlType",
":",
"\"",
"\"",
... | // Integer sets INTEGER type to the column | [
"Integer",
"sets",
"INTEGER",
"type",
"to",
"the",
"column"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/x/sqlgen/columnBuilder.go#L17-L22 |
19,636 | gramework/gramework | fasthttprouter_router.go | newRouter | func newRouter() *router {
r := &router{
RedirectTrailingSlash: true,
RedirectFixedPath: true,
HandleMethodNotAllowed: true,
HandleOPTIONS: true,
cache: &cache{
v: map[string]*msc{
// init default methods
MethodGET: &msc{
v: make(map[string]*cacheRecord),
},
MethodDELET... | go | func newRouter() *router {
r := &router{
RedirectTrailingSlash: true,
RedirectFixedPath: true,
HandleMethodNotAllowed: true,
HandleOPTIONS: true,
cache: &cache{
v: map[string]*msc{
// init default methods
MethodGET: &msc{
v: make(map[string]*cacheRecord),
},
MethodDELET... | [
"func",
"newRouter",
"(",
")",
"*",
"router",
"{",
"r",
":=",
"&",
"router",
"{",
"RedirectTrailingSlash",
":",
"true",
",",
"RedirectFixedPath",
":",
"true",
",",
"HandleMethodNotAllowed",
":",
"true",
",",
"HandleOPTIONS",
":",
"true",
",",
"cache",
":",
... | // newRouter returns a new initialized Router.
// Path auto-correction, including trailing slashes, is enabled by default. | [
"newRouter",
"returns",
"a",
"new",
"initialized",
"Router",
".",
"Path",
"auto",
"-",
"correction",
"including",
"trailing",
"slashes",
"is",
"enabled",
"by",
"default",
"."
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/fasthttprouter_router.go#L122-L166 |
19,637 | gramework/gramework | fasthttprouter_router.go | Recv | func (r *router) Recv(ctx *Context, tracer *log.Entry) {
if rcv := recover(); rcv != nil {
if r.PanicHandler != nil {
r.PanicHandler(ctx, rcv)
} else {
DefaultPanicHandler(ctx, rcv)
}
if tracer != nil {
tracer.WithFields(log.Fields{
"reason": rcv,
"code": ctx.Response.StatusCode(),
}).Err... | go | func (r *router) Recv(ctx *Context, tracer *log.Entry) {
if rcv := recover(); rcv != nil {
if r.PanicHandler != nil {
r.PanicHandler(ctx, rcv)
} else {
DefaultPanicHandler(ctx, rcv)
}
if tracer != nil {
tracer.WithFields(log.Fields{
"reason": rcv,
"code": ctx.Response.StatusCode(),
}).Err... | [
"func",
"(",
"r",
"*",
"router",
")",
"Recv",
"(",
"ctx",
"*",
"Context",
",",
"tracer",
"*",
"log",
".",
"Entry",
")",
"{",
"if",
"rcv",
":=",
"recover",
"(",
")",
";",
"rcv",
"!=",
"nil",
"{",
"if",
"r",
".",
"PanicHandler",
"!=",
"nil",
"{",... | // Recv used to recover after panic. Called if PanicHandler was set | [
"Recv",
"used",
"to",
"recover",
"after",
"panic",
".",
"Called",
"if",
"PanicHandler",
"was",
"set"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/fasthttprouter_router.go#L280-L294 |
19,638 | gramework/gramework | context.go | ContentType | func (ctx *Context) ContentType() string {
return string(ctx.Request.Header.Peek(contentType))
} | go | func (ctx *Context) ContentType() string {
return string(ctx.Request.Header.Peek(contentType))
} | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"ContentType",
"(",
")",
"string",
"{",
"return",
"string",
"(",
"ctx",
".",
"Request",
".",
"Header",
".",
"Peek",
"(",
"contentType",
")",
")",
"\n",
"}"
] | // ContentType returns Content-Type header for current request | [
"ContentType",
"returns",
"Content",
"-",
"Type",
"header",
"for",
"current",
"request"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/context.go#L75-L77 |
19,639 | gramework/gramework | context.go | RouteArg | func (ctx *Context) RouteArg(argName string) string {
v, err := ctx.RouteArgErr(argName)
if err != nil {
return emptyString
}
return v
} | go | func (ctx *Context) RouteArg(argName string) string {
v, err := ctx.RouteArgErr(argName)
if err != nil {
return emptyString
}
return v
} | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"RouteArg",
"(",
"argName",
"string",
")",
"string",
"{",
"v",
",",
"err",
":=",
"ctx",
".",
"RouteArgErr",
"(",
"argName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"emptyString",
"\n",
"}",
"\n",
... | // RouteArg returns an argument value as a string or empty string | [
"RouteArg",
"returns",
"an",
"argument",
"value",
"as",
"a",
"string",
"or",
"empty",
"string"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/context.go#L92-L98 |
19,640 | gramework/gramework | context.go | ToXML | func (ctx *Context) ToXML(v interface{}) ([]byte, error) {
b := bytes.NewBuffer(nil)
err := xml.NewEncoder(b).Encode(v)
return b.Bytes(), err
} | go | func (ctx *Context) ToXML(v interface{}) ([]byte, error) {
b := bytes.NewBuffer(nil)
err := xml.NewEncoder(b).Encode(v)
return b.Bytes(), err
} | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"ToXML",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"b",
":=",
"bytes",
".",
"NewBuffer",
"(",
"nil",
")",
"\n",
"err",
":=",
"xml",
".",
"NewEncoder",
"(",
"b",... | // ToXML encodes xml-encoded value to client | [
"ToXML",
"encodes",
"xml",
"-",
"encoded",
"value",
"to",
"client"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/context.go#L106-L110 |
19,641 | gramework/gramework | context.go | RouteArgErr | func (ctx *Context) RouteArgErr(argName string) (string, error) {
i := ctx.UserValue(argName)
if i == nil {
return emptyString, ErrArgNotFound
}
switch value := i.(type) {
case string:
return value, nil
default:
return fmt.Sprintf(fmtV, i), nil
}
} | go | func (ctx *Context) RouteArgErr(argName string) (string, error) {
i := ctx.UserValue(argName)
if i == nil {
return emptyString, ErrArgNotFound
}
switch value := i.(type) {
case string:
return value, nil
default:
return fmt.Sprintf(fmtV, i), nil
}
} | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"RouteArgErr",
"(",
"argName",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"i",
":=",
"ctx",
".",
"UserValue",
"(",
"argName",
")",
"\n",
"if",
"i",
"==",
"nil",
"{",
"return",
"emptyString",
",",
... | // RouteArgErr returns an argument value as a string or empty string
// and ErrArgNotFound if argument was not found | [
"RouteArgErr",
"returns",
"an",
"argument",
"value",
"as",
"a",
"string",
"or",
"empty",
"string",
"and",
"ErrArgNotFound",
"if",
"argument",
"was",
"not",
"found"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/context.go#L150-L161 |
19,642 | gramework/gramework | context.go | ToTLS | func (ctx *Context) ToTLS() {
u := ctx.URI()
u.SetScheme(https)
ctx.Redirect(u.String(), redirectCode)
} | go | func (ctx *Context) ToTLS() {
u := ctx.URI()
u.SetScheme(https)
ctx.Redirect(u.String(), redirectCode)
} | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"ToTLS",
"(",
")",
"{",
"u",
":=",
"ctx",
".",
"URI",
"(",
")",
"\n",
"u",
".",
"SetScheme",
"(",
"https",
")",
"\n",
"ctx",
".",
"Redirect",
"(",
"u",
".",
"String",
"(",
")",
",",
"redirectCode",
")",
... | // ToTLS redirects user to HTTPS scheme | [
"ToTLS",
"redirects",
"user",
"to",
"HTTPS",
"scheme"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/context.go#L164-L168 |
19,643 | gramework/gramework | context.go | ToJSON | func (ctx *Context) ToJSON(v interface{}) ([]byte, error) {
b := bytes.NewBuffer(nil)
enc := ffjson.NewEncoder(b)
err := enc.Encode(v)
return b.Bytes(), err
} | go | func (ctx *Context) ToJSON(v interface{}) ([]byte, error) {
b := bytes.NewBuffer(nil)
enc := ffjson.NewEncoder(b)
err := enc.Encode(v)
return b.Bytes(), err
} | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"ToJSON",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"b",
":=",
"bytes",
".",
"NewBuffer",
"(",
"nil",
")",
"\n",
"enc",
":=",
"ffjson",
".",
"NewEncoder",
"(",
... | // ToJSON serializes v and returns the result | [
"ToJSON",
"serializes",
"v",
"and",
"returns",
"the",
"result"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/context.go#L176-L181 |
19,644 | gramework/gramework | context.go | UnJSON | func (ctx *Context) UnJSON(v interface{}) error {
return ffjson.NewDecoder().Decode(ctx.Request.Body(), &v)
} | go | func (ctx *Context) UnJSON(v interface{}) error {
return ffjson.NewDecoder().Decode(ctx.Request.Body(), &v)
} | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"UnJSON",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"ffjson",
".",
"NewDecoder",
"(",
")",
".",
"Decode",
"(",
"ctx",
".",
"Request",
".",
"Body",
"(",
")",
",",
"&",
"v",
")",
"\n",
... | // UnJSON deserializes JSON request body to given variable pointer | [
"UnJSON",
"deserializes",
"JSON",
"request",
"body",
"to",
"given",
"variable",
"pointer"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/context.go#L190-L192 |
19,645 | gramework/gramework | app_cache.go | NewCacheOptions | func NewCacheOptions() *CacheOptions {
return &CacheOptions{
TTL: 30 * time.Second,
Cacheable: func(ctx *Context) bool {
if len(ctx.Request.Header.Peek("Authentication")) > 0 {
return false
}
if len(ctx.Cookies.Storage) > 0 {
return false
}
return true
},
CacheKey: func(ctx *Context) [... | go | func NewCacheOptions() *CacheOptions {
return &CacheOptions{
TTL: 30 * time.Second,
Cacheable: func(ctx *Context) bool {
if len(ctx.Request.Header.Peek("Authentication")) > 0 {
return false
}
if len(ctx.Cookies.Storage) > 0 {
return false
}
return true
},
CacheKey: func(ctx *Context) [... | [
"func",
"NewCacheOptions",
"(",
")",
"*",
"CacheOptions",
"{",
"return",
"&",
"CacheOptions",
"{",
"TTL",
":",
"30",
"*",
"time",
".",
"Second",
",",
"Cacheable",
":",
"func",
"(",
"ctx",
"*",
"Context",
")",
"bool",
"{",
"if",
"len",
"(",
"ctx",
"."... | // NewCacheOptions returns a cache options with default settings. | [
"NewCacheOptions",
"returns",
"a",
"cache",
"options",
"with",
"default",
"settings",
"."
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/app_cache.go#L29-L47 |
19,646 | gramework/gramework | x/client/wsHandler.go | WSHandler | func (client *Instance) WSHandler() func(*gramework.Context) error {
up := websocket.FastHTTPUpgrader{}
return func(ctx *gramework.Context) error {
if websocket.FastHTTPIsWebSocketUpgrade(ctx.RequestCtx) {
return up.Upgrade(ctx.RequestCtx, func(conn *websocket.Conn) {
for {
v := <-client.watch(ctx)
... | go | func (client *Instance) WSHandler() func(*gramework.Context) error {
up := websocket.FastHTTPUpgrader{}
return func(ctx *gramework.Context) error {
if websocket.FastHTTPIsWebSocketUpgrade(ctx.RequestCtx) {
return up.Upgrade(ctx.RequestCtx, func(conn *websocket.Conn) {
for {
v := <-client.watch(ctx)
... | [
"func",
"(",
"client",
"*",
"Instance",
")",
"WSHandler",
"(",
")",
"func",
"(",
"*",
"gramework",
".",
"Context",
")",
"error",
"{",
"up",
":=",
"websocket",
".",
"FastHTTPUpgrader",
"{",
"}",
"\n",
"return",
"func",
"(",
"ctx",
"*",
"gramework",
".",... | // WSHandler returns gramework handler | [
"WSHandler",
"returns",
"gramework",
"handler"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/x/client/wsHandler.go#L21-L38 |
19,647 | gramework/gramework | fasthttprouter_tree.go | FindCaseInsensitivePath | func (n *node) FindCaseInsensitivePath(path string, fixTrailingSlash bool) ([]byte, bool) {
return n.findCaseInsensitivePathRec(
path,
toLower(path),
make([]byte, zero, len(path)+one), // preallocate enough memory for new path
[4]byte{}, // empty rune buffer
fixTrailingSlash,
)
} | go | func (n *node) FindCaseInsensitivePath(path string, fixTrailingSlash bool) ([]byte, bool) {
return n.findCaseInsensitivePathRec(
path,
toLower(path),
make([]byte, zero, len(path)+one), // preallocate enough memory for new path
[4]byte{}, // empty rune buffer
fixTrailingSlash,
)
} | [
"func",
"(",
"n",
"*",
"node",
")",
"FindCaseInsensitivePath",
"(",
"path",
"string",
",",
"fixTrailingSlash",
"bool",
")",
"(",
"[",
"]",
"byte",
",",
"bool",
")",
"{",
"return",
"n",
".",
"findCaseInsensitivePathRec",
"(",
"path",
",",
"toLower",
"(",
... | // FindCaseInsensitivePath makes a case-insensitive lookup of the given path
// and tries to find a handler.
// It can optionally also fix trailing slashes.
// It returns the case-corrected path and a bool indicating whether the lookup
// was successful. | [
"FindCaseInsensitivePath",
"makes",
"a",
"case",
"-",
"insensitive",
"lookup",
"of",
"the",
"given",
"path",
"and",
"tries",
"to",
"find",
"a",
"handler",
".",
"It",
"can",
"optionally",
"also",
"fix",
"trailing",
"slashes",
".",
"It",
"returns",
"the",
"cas... | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/fasthttprouter_tree.go#L519-L527 |
19,648 | gramework/gramework | x/sqlgen/create.go | Table | func (cb *CreateBuilder) Table(name string) *CreateTableBuilder {
return &CreateTableBuilder{
name: name,
columns: make([]tableColumn, 0),
}
} | go | func (cb *CreateBuilder) Table(name string) *CreateTableBuilder {
return &CreateTableBuilder{
name: name,
columns: make([]tableColumn, 0),
}
} | [
"func",
"(",
"cb",
"*",
"CreateBuilder",
")",
"Table",
"(",
"name",
"string",
")",
"*",
"CreateTableBuilder",
"{",
"return",
"&",
"CreateTableBuilder",
"{",
"name",
":",
"name",
",",
"columns",
":",
"make",
"(",
"[",
"]",
"tableColumn",
",",
"0",
")",
... | // Table says that we are CREATE-ing
// a TABLE with given name | [
"Table",
"says",
"that",
"we",
"are",
"CREATE",
"-",
"ing",
"a",
"TABLE",
"with",
"given",
"name"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/x/sqlgen/create.go#L26-L31 |
19,649 | gramework/gramework | router_domain.go | Domain | func (app *App) Domain(domain string) *Router {
app.domainListLock.Lock()
if app.domains[domain] == nil {
app.domains[domain] = &Router{
router: newRouter(),
app: app,
}
}
app.domainListLock.Unlock()
return app.domains[domain]
} | go | func (app *App) Domain(domain string) *Router {
app.domainListLock.Lock()
if app.domains[domain] == nil {
app.domains[domain] = &Router{
router: newRouter(),
app: app,
}
}
app.domainListLock.Unlock()
return app.domains[domain]
} | [
"func",
"(",
"app",
"*",
"App",
")",
"Domain",
"(",
"domain",
"string",
")",
"*",
"Router",
"{",
"app",
".",
"domainListLock",
".",
"Lock",
"(",
")",
"\n",
"if",
"app",
".",
"domains",
"[",
"domain",
"]",
"==",
"nil",
"{",
"app",
".",
"domains",
... | // Domain returns a domain router | [
"Domain",
"returns",
"a",
"domain",
"router"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/router_domain.go#L14-L24 |
19,650 | gramework/gramework | app_router.go | ServeDir | func (app *App) ServeDir(path string) func(*Context) {
return app.ServeDirCustom(path, 0, true, false, []string{"index.html", "index.htm"})
} | go | func (app *App) ServeDir(path string) func(*Context) {
return app.ServeDirCustom(path, 0, true, false, []string{"index.html", "index.htm"})
} | [
"func",
"(",
"app",
"*",
"App",
")",
"ServeDir",
"(",
"path",
"string",
")",
"func",
"(",
"*",
"Context",
")",
"{",
"return",
"app",
".",
"ServeDirCustom",
"(",
"path",
",",
"0",
",",
"true",
",",
"false",
",",
"[",
"]",
"string",
"{",
"\"",
"\""... | // ServeDir from a given path | [
"ServeDir",
"from",
"a",
"given",
"path"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/app_router.go#L20-L22 |
19,651 | gramework/gramework | app_router.go | ServeDirCustom | func (app *App) ServeDirCustom(path string, stripSlashes int, compress bool, generateIndexPages bool, indexNames []string) func(*Context) {
if indexNames == nil {
indexNames = []string{}
}
fs := &fasthttp.FS{
Root: path,
IndexNames: indexNames,
GenerateIndexPages: generateIndexPag... | go | func (app *App) ServeDirCustom(path string, stripSlashes int, compress bool, generateIndexPages bool, indexNames []string) func(*Context) {
if indexNames == nil {
indexNames = []string{}
}
fs := &fasthttp.FS{
Root: path,
IndexNames: indexNames,
GenerateIndexPages: generateIndexPag... | [
"func",
"(",
"app",
"*",
"App",
")",
"ServeDirCustom",
"(",
"path",
"string",
",",
"stripSlashes",
"int",
",",
"compress",
"bool",
",",
"generateIndexPages",
"bool",
",",
"indexNames",
"[",
"]",
"string",
")",
"func",
"(",
"*",
"Context",
")",
"{",
"if",... | // ServeDirCustom gives you ability to serve a dir with custom settings | [
"ServeDirCustom",
"gives",
"you",
"ability",
"to",
"serve",
"a",
"dir",
"with",
"custom",
"settings"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/app_router.go#L25-L46 |
19,652 | gramework/gramework | app_router.go | ServeDirNoCache | func (app *App) ServeDirNoCache(path string) func(*Context) {
return app.ServeDirNoCacheCustom(path, 0, true, false, nil)
} | go | func (app *App) ServeDirNoCache(path string) func(*Context) {
return app.ServeDirNoCacheCustom(path, 0, true, false, nil)
} | [
"func",
"(",
"app",
"*",
"App",
")",
"ServeDirNoCache",
"(",
"path",
"string",
")",
"func",
"(",
"*",
"Context",
")",
"{",
"return",
"app",
".",
"ServeDirNoCacheCustom",
"(",
"path",
",",
"0",
",",
"true",
",",
"false",
",",
"nil",
")",
"\n",
"}"
] | // ServeDirNoCache gives you ability to serve a dir without caching | [
"ServeDirNoCache",
"gives",
"you",
"ability",
"to",
"serve",
"a",
"dir",
"without",
"caching"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/app_router.go#L49-L51 |
19,653 | gramework/gramework | app_router.go | ServeDirNoCacheCustom | func (app *App) ServeDirNoCacheCustom(path string, stripSlashes int, compress bool, generateIndexPages bool, indexNames []string) func(*Context) {
if indexNames == nil {
indexNames = []string{}
}
fs := &fasthttp.FS{
Root: path,
IndexNames: indexNames,
GenerateIndexPages: generateI... | go | func (app *App) ServeDirNoCacheCustom(path string, stripSlashes int, compress bool, generateIndexPages bool, indexNames []string) func(*Context) {
if indexNames == nil {
indexNames = []string{}
}
fs := &fasthttp.FS{
Root: path,
IndexNames: indexNames,
GenerateIndexPages: generateI... | [
"func",
"(",
"app",
"*",
"App",
")",
"ServeDirNoCacheCustom",
"(",
"path",
"string",
",",
"stripSlashes",
"int",
",",
"compress",
"bool",
",",
"generateIndexPages",
"bool",
",",
"indexNames",
"[",
"]",
"string",
")",
"func",
"(",
"*",
"Context",
")",
"{",
... | // ServeDirNoCacheCustom gives you ability to serve a dir with custom settings without caching | [
"ServeDirNoCacheCustom",
"gives",
"you",
"ability",
"to",
"serve",
"a",
"dir",
"with",
"custom",
"settings",
"without",
"caching"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/app_router.go#L54-L84 |
19,654 | gramework/gramework | regFlags.go | AddFlag | func (app *App) AddFlag(f Flag) {
if app.flagsQueue == nil {
app.flagsQueue = make([]Flag, 0)
}
app.flagsQueue = append(app.flagsQueue, f)
} | go | func (app *App) AddFlag(f Flag) {
if app.flagsQueue == nil {
app.flagsQueue = make([]Flag, 0)
}
app.flagsQueue = append(app.flagsQueue, f)
} | [
"func",
"(",
"app",
"*",
"App",
")",
"AddFlag",
"(",
"f",
"Flag",
")",
"{",
"if",
"app",
".",
"flagsQueue",
"==",
"nil",
"{",
"app",
".",
"flagsQueue",
"=",
"make",
"(",
"[",
"]",
"Flag",
",",
"0",
")",
"\n",
"}",
"\n",
"app",
".",
"flagsQueue"... | // AddFlag adds a Flag to flag queue that will be
// parsed if flags wasn't parsed yet | [
"AddFlag",
"adds",
"a",
"Flag",
"to",
"flag",
"queue",
"that",
"will",
"be",
"parsed",
"if",
"flags",
"wasn",
"t",
"parsed",
"yet"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/regFlags.go#L29-L34 |
19,655 | gramework/gramework | regFlags.go | RegFlags | func (app *App) RegFlags() {
if app.Flags.values == nil {
app.Flags.values = make(map[string]Flag)
}
app.flagsRegistered = true
for _, v := range app.flagsQueue {
app.Flags.values[v.Name] = Flag{
Name: v.Name,
Description: v.Description,
Default: v.Default,
Value: flag.String(v.Name... | go | func (app *App) RegFlags() {
if app.Flags.values == nil {
app.Flags.values = make(map[string]Flag)
}
app.flagsRegistered = true
for _, v := range app.flagsQueue {
app.Flags.values[v.Name] = Flag{
Name: v.Name,
Description: v.Description,
Default: v.Default,
Value: flag.String(v.Name... | [
"func",
"(",
"app",
"*",
"App",
")",
"RegFlags",
"(",
")",
"{",
"if",
"app",
".",
"Flags",
".",
"values",
"==",
"nil",
"{",
"app",
".",
"Flags",
".",
"values",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"Flag",
")",
"\n",
"}",
"\n",
"app",
... | // RegFlags registers current flag queue in flag parser | [
"RegFlags",
"registers",
"current",
"flag",
"queue",
"in",
"flag",
"parser"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/regFlags.go#L37-L50 |
19,656 | gramework/gramework | regFlags.go | GetStringFlag | func (app *App) GetStringFlag(name string) (string, bool) {
if !flag.Parsed() && !flagsDisabled {
flag.Parse()
}
if app.Flags.values != nil {
if bindFlag, ok := app.Flags.values[name]; ok {
return *bindFlag.Value, ok
}
}
return "", false
} | go | func (app *App) GetStringFlag(name string) (string, bool) {
if !flag.Parsed() && !flagsDisabled {
flag.Parse()
}
if app.Flags.values != nil {
if bindFlag, ok := app.Flags.values[name]; ok {
return *bindFlag.Value, ok
}
}
return "", false
} | [
"func",
"(",
"app",
"*",
"App",
")",
"GetStringFlag",
"(",
"name",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"!",
"flag",
".",
"Parsed",
"(",
")",
"&&",
"!",
"flagsDisabled",
"{",
"flag",
".",
"Parse",
"(",
")",
"\n",
"}",
"\n",
... | // GetStringFlag return command line app flag value by name and false if not exists | [
"GetStringFlag",
"return",
"command",
"line",
"app",
"flag",
"value",
"by",
"name",
"and",
"false",
"if",
"not",
"exists"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/regFlags.go#L53-L64 |
19,657 | gramework/gramework | middleware.go | Use | func (app *App) Use(middleware interface{}) error {
if middleware == nil {
return ErrEmptyMiddleware
}
processor, err := app.middlewareProcessor(middleware)
app.middlewaresMu.Lock()
if err == nil {
app.middlewares = append(app.middlewares, processor)
}
app.middlewaresMu.Unlock()
return err
} | go | func (app *App) Use(middleware interface{}) error {
if middleware == nil {
return ErrEmptyMiddleware
}
processor, err := app.middlewareProcessor(middleware)
app.middlewaresMu.Lock()
if err == nil {
app.middlewares = append(app.middlewares, processor)
}
app.middlewaresMu.Unlock()
return err
} | [
"func",
"(",
"app",
"*",
"App",
")",
"Use",
"(",
"middleware",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"middleware",
"==",
"nil",
"{",
"return",
"ErrEmptyMiddleware",
"\n",
"}",
"\n",
"processor",
",",
"err",
":=",
"app",
".",
"middlewareProcesso... | // Use the middleware before request processing | [
"Use",
"the",
"middleware",
"before",
"request",
"processing"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/middleware.go#L35-L47 |
19,658 | gramework/gramework | middleware.go | UsePre | func (app *App) UsePre(middleware interface{}) error {
if middleware == nil {
return ErrEmptyMiddleware
}
processor, err := app.middlewareProcessor(middleware)
app.preMiddlewaresMu.Lock()
if err == nil {
app.preMiddlewares = append(app.preMiddlewares, processor)
}
app.preMiddlewaresMu.Unlock()
return err
} | go | func (app *App) UsePre(middleware interface{}) error {
if middleware == nil {
return ErrEmptyMiddleware
}
processor, err := app.middlewareProcessor(middleware)
app.preMiddlewaresMu.Lock()
if err == nil {
app.preMiddlewares = append(app.preMiddlewares, processor)
}
app.preMiddlewaresMu.Unlock()
return err
} | [
"func",
"(",
"app",
"*",
"App",
")",
"UsePre",
"(",
"middleware",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"middleware",
"==",
"nil",
"{",
"return",
"ErrEmptyMiddleware",
"\n",
"}",
"\n",
"processor",
",",
"err",
":=",
"app",
".",
"middlewareProce... | // UsePre registers middleware before any other middleware. Use only for metrics or access control! | [
"UsePre",
"registers",
"middleware",
"before",
"any",
"other",
"middleware",
".",
"Use",
"only",
"for",
"metrics",
"or",
"access",
"control!"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/middleware.go#L50-L62 |
19,659 | gramework/gramework | middleware.go | UseAfterRequest | func (app *App) UseAfterRequest(middleware interface{}) error {
if middleware == nil {
return ErrEmptyMiddleware
}
processor, err := app.middlewareProcessor(middleware)
app.middlewaresAfterRequestMu.Lock()
if err == nil {
app.middlewaresAfterRequest = append(app.middlewaresAfterRequest, processor)
}
app.mid... | go | func (app *App) UseAfterRequest(middleware interface{}) error {
if middleware == nil {
return ErrEmptyMiddleware
}
processor, err := app.middlewareProcessor(middleware)
app.middlewaresAfterRequestMu.Lock()
if err == nil {
app.middlewaresAfterRequest = append(app.middlewaresAfterRequest, processor)
}
app.mid... | [
"func",
"(",
"app",
"*",
"App",
")",
"UseAfterRequest",
"(",
"middleware",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"middleware",
"==",
"nil",
"{",
"return",
"ErrEmptyMiddleware",
"\n",
"}",
"\n\n",
"processor",
",",
"err",
":=",
"app",
".",
"midd... | // UseAfterRequest the middleware after request processing | [
"UseAfterRequest",
"the",
"middleware",
"after",
"request",
"processing"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/middleware.go#L65-L78 |
19,660 | gramework/gramework | context_logHeaders.go | LogHeaders | func (ctx *Context) LogHeaders() {
ctx.Request.Header.VisitAll(func(k, v []byte) {
ctx.Logger.Debugf("%s = [%s]\n", k, v)
})
} | go | func (ctx *Context) LogHeaders() {
ctx.Request.Header.VisitAll(func(k, v []byte) {
ctx.Logger.Debugf("%s = [%s]\n", k, v)
})
} | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"LogHeaders",
"(",
")",
"{",
"ctx",
".",
"Request",
".",
"Header",
".",
"VisitAll",
"(",
"func",
"(",
"k",
",",
"v",
"[",
"]",
"byte",
")",
"{",
"ctx",
".",
"Logger",
".",
"Debugf",
"(",
"\"",
"\\n",
"\"... | // LogHeaders logs all request headers for debug | [
"LogHeaders",
"logs",
"all",
"request",
"headers",
"for",
"debug"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/context_logHeaders.go#L14-L18 |
19,661 | gramework/gramework | context_proxy.go | Proxy | func (ctx *Context) Proxy(url string) (err error) {
proxyReq := fasthttp.AcquireRequest()
ctx.Request.CopyTo(proxyReq)
proxyReq.SetRequestURI(url)
err = fasthttp.Do(proxyReq, &ctx.Response)
fasthttp.ReleaseRequest(proxyReq)
return
} | go | func (ctx *Context) Proxy(url string) (err error) {
proxyReq := fasthttp.AcquireRequest()
ctx.Request.CopyTo(proxyReq)
proxyReq.SetRequestURI(url)
err = fasthttp.Do(proxyReq, &ctx.Response)
fasthttp.ReleaseRequest(proxyReq)
return
} | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"Proxy",
"(",
"url",
"string",
")",
"(",
"err",
"error",
")",
"{",
"proxyReq",
":=",
"fasthttp",
".",
"AcquireRequest",
"(",
")",
"\n",
"ctx",
".",
"Request",
".",
"CopyTo",
"(",
"proxyReq",
")",
"\n",
"proxyR... | // Proxy request to given url | [
"Proxy",
"request",
"to",
"given",
"url"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/context_proxy.go#L18-L27 |
19,662 | gramework/gramework | healthchecks/hc.go | Register | func Register(r interface{}, collectors ...func() (statKey string, stats interface{})) error {
return doReg(r, collectors, true, true)
} | go | func Register(r interface{}, collectors ...func() (statKey string, stats interface{})) error {
return doReg(r, collectors, true, true)
} | [
"func",
"Register",
"(",
"r",
"interface",
"{",
"}",
",",
"collectors",
"...",
"func",
"(",
")",
"(",
"statKey",
"string",
",",
"stats",
"interface",
"{",
"}",
")",
")",
"error",
"{",
"return",
"doReg",
"(",
"r",
",",
"collectors",
",",
"true",
",",
... | // Register both ping and healthcheck endpoints | [
"Register",
"both",
"ping",
"and",
"healthcheck",
"endpoints"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/healthchecks/hc.go#L4-L6 |
19,663 | gramework/gramework | healthchecks/hc.go | RegisterHealthcheck | func RegisterHealthcheck(r interface{}, collectors ...func() (statKey string, stats interface{})) error {
return doReg(r, collectors, false, true)
} | go | func RegisterHealthcheck(r interface{}, collectors ...func() (statKey string, stats interface{})) error {
return doReg(r, collectors, false, true)
} | [
"func",
"RegisterHealthcheck",
"(",
"r",
"interface",
"{",
"}",
",",
"collectors",
"...",
"func",
"(",
")",
"(",
"statKey",
"string",
",",
"stats",
"interface",
"{",
"}",
")",
")",
"error",
"{",
"return",
"doReg",
"(",
"r",
",",
"collectors",
",",
"fal... | // RegisterHealthcheck registers healthcheck endpoint | [
"RegisterHealthcheck",
"registers",
"healthcheck",
"endpoint"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/healthchecks/hc.go#L14-L16 |
19,664 | gramework/gramework | infrastructure/infrastructure_New.go | New | func New() *Infrastructure {
return &Infrastructure{
Lock: new(sync.RWMutex),
Services: make(map[string]*Service),
UpdateTimestamp: time.Now().UnixNano(),
}
} | go | func New() *Infrastructure {
return &Infrastructure{
Lock: new(sync.RWMutex),
Services: make(map[string]*Service),
UpdateTimestamp: time.Now().UnixNano(),
}
} | [
"func",
"New",
"(",
")",
"*",
"Infrastructure",
"{",
"return",
"&",
"Infrastructure",
"{",
"Lock",
":",
"new",
"(",
"sync",
".",
"RWMutex",
")",
",",
"Services",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"Service",
")",
",",
"UpdateTimestamp",
... | // New initializes an empty infrastructure | [
"New",
"initializes",
"an",
"empty",
"infrastructure"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/infrastructure/infrastructure_New.go#L9-L15 |
19,665 | gramework/gramework | behind/akamai/internal/portWhitelist/portWhitelist.go | IsPortInRange | func IsPortInRange(port string) bool {
if strings.Contains(port, ",") {
ports := strings.Split(port, ",")
for _, p := range ports {
if strings.Contains(p, "-") && IsPortInRange(p) {
return true
}
for _, allowedPort := range allowedPorts {
if p == allowedPort {
return true
}
}
}
re... | go | func IsPortInRange(port string) bool {
if strings.Contains(port, ",") {
ports := strings.Split(port, ",")
for _, p := range ports {
if strings.Contains(p, "-") && IsPortInRange(p) {
return true
}
for _, allowedPort := range allowedPorts {
if p == allowedPort {
return true
}
}
}
re... | [
"func",
"IsPortInRange",
"(",
"port",
"string",
")",
"bool",
"{",
"if",
"strings",
".",
"Contains",
"(",
"port",
",",
"\"",
"\"",
")",
"{",
"ports",
":=",
"strings",
".",
"Split",
"(",
"port",
",",
"\"",
"\"",
")",
"\n",
"for",
"_",
",",
"p",
":=... | // IsPortInRange checks if port is in whitelist. | [
"IsPortInRange",
"checks",
"if",
"port",
"is",
"in",
"whitelist",
"."
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/behind/akamai/internal/portWhitelist/portWhitelist.go#L31-L78 |
19,666 | gramework/gramework | x/sqlgen/insert.go | Insert | func Insert(table string) *InsertBuilder {
return &InsertBuilder{
tableName: table,
query: fmt.Sprintln(`INSERT INTO`, table),
lock: new(sync.Mutex),
}
} | go | func Insert(table string) *InsertBuilder {
return &InsertBuilder{
tableName: table,
query: fmt.Sprintln(`INSERT INTO`, table),
lock: new(sync.Mutex),
}
} | [
"func",
"Insert",
"(",
"table",
"string",
")",
"*",
"InsertBuilder",
"{",
"return",
"&",
"InsertBuilder",
"{",
"tableName",
":",
"table",
",",
"query",
":",
"fmt",
".",
"Sprintln",
"(",
"`INSERT INTO`",
",",
"table",
")",
",",
"lock",
":",
"new",
"(",
... | // Insert statement builder generates
// an insert statement using `?` placeholders
// for values | [
"Insert",
"statement",
"builder",
"generates",
"an",
"insert",
"statement",
"using",
"?",
"placeholders",
"for",
"values"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/x/sqlgen/insert.go#L12-L18 |
19,667 | gramework/gramework | x/sqlgen/insert.go | PreparedInsert | func PreparedInsert(table string) *InsertBuilder {
i := Insert(table)
i.prepared = true
return i
} | go | func PreparedInsert(table string) *InsertBuilder {
i := Insert(table)
i.prepared = true
return i
} | [
"func",
"PreparedInsert",
"(",
"table",
"string",
")",
"*",
"InsertBuilder",
"{",
"i",
":=",
"Insert",
"(",
"table",
")",
"\n",
"i",
".",
"prepared",
"=",
"true",
"\n",
"return",
"i",
"\n",
"}"
] | // PreparedInsert statement builder generates
// the insert SQL statement with values built
// in the statement without using placeholders | [
"PreparedInsert",
"statement",
"builder",
"generates",
"the",
"insert",
"SQL",
"statement",
"with",
"values",
"built",
"in",
"the",
"statement",
"without",
"using",
"placeholders"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/x/sqlgen/insert.go#L23-L27 |
19,668 | gramework/gramework | x/sqlgen/insert.go | Columns | func (b *InsertBuilder) Columns(columns ...string) *InsertBuilder {
b.lock.Lock()
b.columns = columns
b.query = fmt.Sprintf(`%s(`, b.query)
for i, column := range columns {
b.query = fmt.Sprintf(`%s%s`, b.query, column)
if i < len(columns)-1 {
b.query = fmt.Sprintf(`%s,`, b.query)
}
}
b.query = fmt.Sprin... | go | func (b *InsertBuilder) Columns(columns ...string) *InsertBuilder {
b.lock.Lock()
b.columns = columns
b.query = fmt.Sprintf(`%s(`, b.query)
for i, column := range columns {
b.query = fmt.Sprintf(`%s%s`, b.query, column)
if i < len(columns)-1 {
b.query = fmt.Sprintf(`%s,`, b.query)
}
}
b.query = fmt.Sprin... | [
"func",
"(",
"b",
"*",
"InsertBuilder",
")",
"Columns",
"(",
"columns",
"...",
"string",
")",
"*",
"InsertBuilder",
"{",
"b",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"b",
".",
"columns",
"=",
"columns",
"\n",
"b",
".",
"query",
"=",
"fmt",
".",
... | // Columns defines column list | [
"Columns",
"defines",
"column",
"list"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/x/sqlgen/insert.go#L30-L43 |
19,669 | gramework/gramework | x/sqlgen/insert.go | Values | func (b *InsertBuilder) Values(columnValues ...interface{}) *InsertBuilder {
b.lock.Lock()
sqlValue := "("
if b.prepared {
for k, columnValue := range columnValues {
switch v := columnValue.(type) {
case string:
sqlValue = fmt.Sprintf("%s'%s'", sqlValue, strings.Replace(v, "'", "''", -1))
default:
... | go | func (b *InsertBuilder) Values(columnValues ...interface{}) *InsertBuilder {
b.lock.Lock()
sqlValue := "("
if b.prepared {
for k, columnValue := range columnValues {
switch v := columnValue.(type) {
case string:
sqlValue = fmt.Sprintf("%s'%s'", sqlValue, strings.Replace(v, "'", "''", -1))
default:
... | [
"func",
"(",
"b",
"*",
"InsertBuilder",
")",
"Values",
"(",
"columnValues",
"...",
"interface",
"{",
"}",
")",
"*",
"InsertBuilder",
"{",
"b",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"sqlValue",
":=",
"\"",
"\"",
"\n",
"if",
"b",
".",
"prepared",
... | // Values appends column values to the query | [
"Values",
"appends",
"column",
"values",
"to",
"the",
"query"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/x/sqlgen/insert.go#L46-L74 |
19,670 | gramework/gramework | x/sqlgen/insert.go | Build | func (b *InsertBuilder) Build() string {
b.lock.Lock()
defer b.lock.Unlock()
return fmt.Sprintf("%s\n VALUES %s;", b.query, strings.Join(b.sqlValues, ", \n "))
} | go | func (b *InsertBuilder) Build() string {
b.lock.Lock()
defer b.lock.Unlock()
return fmt.Sprintf("%s\n VALUES %s;", b.query, strings.Join(b.sqlValues, ", \n "))
} | [
"func",
"(",
"b",
"*",
"InsertBuilder",
")",
"Build",
"(",
")",
"string",
"{",
"b",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
","... | // Build the query | [
"Build",
"the",
"query"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/x/sqlgen/insert.go#L77-L81 |
19,671 | gramework/gramework | graphiql/graphiql.go | Handler | func Handler(ctx *gramework.Context) {
if _, err := ctx.HTML().WriteString(tpl); err != nil {
ctx.Logger.WithError(err).WithField("package", "mw/graphiql").Error("could not send template")
}
} | go | func Handler(ctx *gramework.Context) {
if _, err := ctx.HTML().WriteString(tpl); err != nil {
ctx.Logger.WithError(err).WithField("package", "mw/graphiql").Error("could not send template")
}
} | [
"func",
"Handler",
"(",
"ctx",
"*",
"gramework",
".",
"Context",
")",
"{",
"if",
"_",
",",
"err",
":=",
"ctx",
".",
"HTML",
"(",
")",
".",
"WriteString",
"(",
"tpl",
")",
";",
"err",
"!=",
"nil",
"{",
"ctx",
".",
"Logger",
".",
"WithError",
"(",
... | // Handler serves standalone graphiql HTML. | [
"Handler",
"serves",
"standalone",
"graphiql",
"HTML",
"."
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/graphiql/graphiql.go#L12-L16 |
19,672 | gramework/gramework | cookie.go | GetCookieDomain | func (ctx *Context) GetCookieDomain() (domain string, wasConfigured bool) {
return ctx.App.cookieDomain, len(ctx.App.cookieDomain) > 0
} | go | func (ctx *Context) GetCookieDomain() (domain string, wasConfigured bool) {
return ctx.App.cookieDomain, len(ctx.App.cookieDomain) > 0
} | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"GetCookieDomain",
"(",
")",
"(",
"domain",
"string",
",",
"wasConfigured",
"bool",
")",
"{",
"return",
"ctx",
".",
"App",
".",
"cookieDomain",
",",
"len",
"(",
"ctx",
".",
"App",
".",
"cookieDomain",
")",
">",
... | // GetCookieDomain returns previously configured cookie domain and if cookie domain
// was configured at all | [
"GetCookieDomain",
"returns",
"previously",
"configured",
"cookie",
"domain",
"and",
"if",
"cookie",
"domain",
"was",
"configured",
"at",
"all"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/cookie.go#L23-L25 |
19,673 | gramework/gramework | cookie.go | Set | func (c *Cookies) Set(key, value string) {
c.Mu.Lock()
if c.Storage == nil {
c.Storage = make(map[string]string, zero)
}
c.Storage[key] = value
c.Mu.Unlock()
} | go | func (c *Cookies) Set(key, value string) {
c.Mu.Lock()
if c.Storage == nil {
c.Storage = make(map[string]string, zero)
}
c.Storage[key] = value
c.Mu.Unlock()
} | [
"func",
"(",
"c",
"*",
"Cookies",
")",
"Set",
"(",
"key",
",",
"value",
"string",
")",
"{",
"c",
".",
"Mu",
".",
"Lock",
"(",
")",
"\n",
"if",
"c",
".",
"Storage",
"==",
"nil",
"{",
"c",
".",
"Storage",
"=",
"make",
"(",
"map",
"[",
"string",... | // Set a cookie with given key to the value | [
"Set",
"a",
"cookie",
"with",
"given",
"key",
"to",
"the",
"value"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/cookie.go#L56-L63 |
19,674 | gramework/gramework | cookie.go | Get | func (c *Cookies) Get(key string) (string, bool) {
c.Mu.Lock()
if c.Storage == nil {
c.Storage = make(map[string]string, zero)
c.Mu.Unlock()
return emptyString, false
}
if v, ok := c.Storage[key]; ok {
c.Mu.Unlock()
return v, ok
}
c.Mu.Unlock()
return emptyString, false
} | go | func (c *Cookies) Get(key string) (string, bool) {
c.Mu.Lock()
if c.Storage == nil {
c.Storage = make(map[string]string, zero)
c.Mu.Unlock()
return emptyString, false
}
if v, ok := c.Storage[key]; ok {
c.Mu.Unlock()
return v, ok
}
c.Mu.Unlock()
return emptyString, false
} | [
"func",
"(",
"c",
"*",
"Cookies",
")",
"Get",
"(",
"key",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"c",
".",
"Mu",
".",
"Lock",
"(",
")",
"\n",
"if",
"c",
".",
"Storage",
"==",
"nil",
"{",
"c",
".",
"Storage",
"=",
"make",
"(",
... | // Get a cookie by given key | [
"Get",
"a",
"cookie",
"by",
"given",
"key"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/cookie.go#L66-L79 |
19,675 | gramework/gramework | cookie.go | Exists | func (c *Cookies) Exists(key string) bool {
c.Mu.Lock()
if c.Storage == nil {
c.Storage = make(map[string]string, zero)
c.Mu.Unlock()
return false
}
if _, ok := c.Storage[key]; ok {
c.Mu.Unlock()
return ok
}
c.Mu.Unlock()
return false
} | go | func (c *Cookies) Exists(key string) bool {
c.Mu.Lock()
if c.Storage == nil {
c.Storage = make(map[string]string, zero)
c.Mu.Unlock()
return false
}
if _, ok := c.Storage[key]; ok {
c.Mu.Unlock()
return ok
}
c.Mu.Unlock()
return false
} | [
"func",
"(",
"c",
"*",
"Cookies",
")",
"Exists",
"(",
"key",
"string",
")",
"bool",
"{",
"c",
".",
"Mu",
".",
"Lock",
"(",
")",
"\n",
"if",
"c",
".",
"Storage",
"==",
"nil",
"{",
"c",
".",
"Storage",
"=",
"make",
"(",
"map",
"[",
"string",
"]... | // Exists reports if the given key exists for current request | [
"Exists",
"reports",
"if",
"the",
"given",
"key",
"exists",
"for",
"current",
"request"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/cookie.go#L82-L95 |
19,676 | gramework/gramework | subroute.go | HTTP | func (r *SubRouter) HTTP() *SubRouter {
switch parent := r.parent.(type) {
case *SubRouter:
return parent.HTTP()
case *Router:
return &SubRouter{
parent: parent,
prefix: r.prefix,
}
default:
Errorf("[HIGH SEVERITY BUG]: unreachable case found! Expected *SubRouter or *Router, got %T! Returning nil!", p... | go | func (r *SubRouter) HTTP() *SubRouter {
switch parent := r.parent.(type) {
case *SubRouter:
return parent.HTTP()
case *Router:
return &SubRouter{
parent: parent,
prefix: r.prefix,
}
default:
Errorf("[HIGH SEVERITY BUG]: unreachable case found! Expected *SubRouter or *Router, got %T! Returning nil!", p... | [
"func",
"(",
"r",
"*",
"SubRouter",
")",
"HTTP",
"(",
")",
"*",
"SubRouter",
"{",
"switch",
"parent",
":=",
"r",
".",
"parent",
".",
"(",
"type",
")",
"{",
"case",
"*",
"SubRouter",
":",
"return",
"parent",
".",
"HTTP",
"(",
")",
"\n",
"case",
"*... | // HTTP returns SubRouter for http requests with given r.prefix | [
"HTTP",
"returns",
"SubRouter",
"for",
"http",
"requests",
"with",
"given",
"r",
".",
"prefix"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/subroute.go#L148-L162 |
19,677 | gramework/gramework | subroute.go | HTTPS | func (r *SubRouter) HTTPS() *SubRouter {
switch parent := r.parent.(type) {
case *SubRouter:
return parent.HTTPS()
case *Router:
return &SubRouter{
parent: parent,
prefix: r.prefix,
}
default:
Errorf("[HIGH SEVERITY BUG]: unreachable case found! Expected *SubRouter or *Router, got %T! Returning nil!",... | go | func (r *SubRouter) HTTPS() *SubRouter {
switch parent := r.parent.(type) {
case *SubRouter:
return parent.HTTPS()
case *Router:
return &SubRouter{
parent: parent,
prefix: r.prefix,
}
default:
Errorf("[HIGH SEVERITY BUG]: unreachable case found! Expected *SubRouter or *Router, got %T! Returning nil!",... | [
"func",
"(",
"r",
"*",
"SubRouter",
")",
"HTTPS",
"(",
")",
"*",
"SubRouter",
"{",
"switch",
"parent",
":=",
"r",
".",
"parent",
".",
"(",
"type",
")",
"{",
"case",
"*",
"SubRouter",
":",
"return",
"parent",
".",
"HTTPS",
"(",
")",
"\n",
"case",
... | // HTTPS returns SubRouter for https requests with given r.prefix | [
"HTTPS",
"returns",
"SubRouter",
"for",
"https",
"requests",
"with",
"given",
"r",
".",
"prefix"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/subroute.go#L165-L179 |
19,678 | gramework/gramework | context_gql.go | DecodeGQL | func (ctx *Context) DecodeGQL() (*GQLRequest, error) {
r := &GQLRequest{}
if string(ctx.Method()) == GET {
query := ctx.GETParam("query")
if len(query) == 0 {
return nil, ErrInvalidGQLRequest
}
r.Query = query[0]
if operationName := ctx.GETParam("operationName"); len(operationName) != 0 {
r.Operatio... | go | func (ctx *Context) DecodeGQL() (*GQLRequest, error) {
r := &GQLRequest{}
if string(ctx.Method()) == GET {
query := ctx.GETParam("query")
if len(query) == 0 {
return nil, ErrInvalidGQLRequest
}
r.Query = query[0]
if operationName := ctx.GETParam("operationName"); len(operationName) != 0 {
r.Operatio... | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"DecodeGQL",
"(",
")",
"(",
"*",
"GQLRequest",
",",
"error",
")",
"{",
"r",
":=",
"&",
"GQLRequest",
"{",
"}",
"\n\n",
"if",
"string",
"(",
"ctx",
".",
"Method",
"(",
")",
")",
"==",
"GET",
"{",
"query",
... | // DecodeGQL parses GraphQL request and returns data from it | [
"DecodeGQL",
"parses",
"GraphQL",
"request",
"and",
"returns",
"data",
"from",
"it"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/context_gql.go#L8-L43 |
19,679 | gramework/gramework | firewall.go | NewRequest | func (fw *firewall) NewRequest(ctx *Context) (shouldBeBlocked bool, remoteAddr string) {
if ctx == nil || ctx.RemoteAddr().String() == "0.0.0.0" {
return false, ""
}
// Get the remote addresse of the request
remoteAddr = ctx.RemoteIP().String()
// Check if this remote address is blocked
if fw.isBlocked(remoteA... | go | func (fw *firewall) NewRequest(ctx *Context) (shouldBeBlocked bool, remoteAddr string) {
if ctx == nil || ctx.RemoteAddr().String() == "0.0.0.0" {
return false, ""
}
// Get the remote addresse of the request
remoteAddr = ctx.RemoteIP().String()
// Check if this remote address is blocked
if fw.isBlocked(remoteA... | [
"func",
"(",
"fw",
"*",
"firewall",
")",
"NewRequest",
"(",
"ctx",
"*",
"Context",
")",
"(",
"shouldBeBlocked",
"bool",
",",
"remoteAddr",
"string",
")",
"{",
"if",
"ctx",
"==",
"nil",
"||",
"ctx",
".",
"RemoteAddr",
"(",
")",
".",
"String",
"(",
")"... | // NewRequest tells the firewall, that a new request happened.
// True is returned, if this request should be blocked,
// because the IP is on the block list.
// The remote address is always returned for logging purpose. | [
"NewRequest",
"tells",
"the",
"firewall",
"that",
"a",
"new",
"request",
"happened",
".",
"True",
"is",
"returned",
"if",
"this",
"request",
"should",
"be",
"blocked",
"because",
"the",
"IP",
"is",
"on",
"the",
"block",
"list",
".",
"The",
"remote",
"addre... | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/firewall.go#L27-L43 |
19,680 | gramework/gramework | firewall.go | isBlocked | func (fw *firewall) isBlocked(remoteAddr string) bool {
fw.blockListMutex.Lock()
// Check if the remote address exists in the blocked map
_, exists := fw.blockList[remoteAddr]
fw.blockListMutex.Unlock()
return exists
} | go | func (fw *firewall) isBlocked(remoteAddr string) bool {
fw.blockListMutex.Lock()
// Check if the remote address exists in the blocked map
_, exists := fw.blockList[remoteAddr]
fw.blockListMutex.Unlock()
return exists
} | [
"func",
"(",
"fw",
"*",
"firewall",
")",
"isBlocked",
"(",
"remoteAddr",
"string",
")",
"bool",
"{",
"fw",
".",
"blockListMutex",
".",
"Lock",
"(",
")",
"\n\n",
"// Check if the remote address exists in the blocked map",
"_",
",",
"exists",
":=",
"fw",
".",
"b... | // isBlocked checks if the remote address is blocked | [
"isBlocked",
"checks",
"if",
"the",
"remote",
"address",
"is",
"blocked"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/firewall.go#L46-L54 |
19,681 | gramework/gramework | mw/xhostname/xhostname.go | Setup | func Setup(app *gramework.App) {
err := app.UseAfterRequest(serveXHost)
if err != nil {
app.Logger.WithError(err).WithField("package", "mw/xhostname").Error("could not register middleware")
}
} | go | func Setup(app *gramework.App) {
err := app.UseAfterRequest(serveXHost)
if err != nil {
app.Logger.WithError(err).WithField("package", "mw/xhostname").Error("could not register middleware")
}
} | [
"func",
"Setup",
"(",
"app",
"*",
"gramework",
".",
"App",
")",
"{",
"err",
":=",
"app",
".",
"UseAfterRequest",
"(",
"serveXHost",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"app",
".",
"Logger",
".",
"WithError",
"(",
"err",
")",
".",
"WithField",
... | // Setup registers middleware in the provided app | [
"Setup",
"registers",
"middleware",
"in",
"the",
"provided",
"app"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/mw/xhostname/xhostname.go#L41-L46 |
19,682 | gramework/gramework | grypto/internal/mcf/mcf.go | Encode | func Encode(providerName []byte, params string, salt []byte, key []byte) (res []byte) {
salt64 := encodeBase64(salt)
key64 := encodeBase64(key)
// final res len = len(providerName) + len(params) + len(salt) + len(key) + 4, because we need 4 dividers
res = append(res, Divider)
res = append(res, providerName...)
re... | go | func Encode(providerName []byte, params string, salt []byte, key []byte) (res []byte) {
salt64 := encodeBase64(salt)
key64 := encodeBase64(key)
// final res len = len(providerName) + len(params) + len(salt) + len(key) + 4, because we need 4 dividers
res = append(res, Divider)
res = append(res, providerName...)
re... | [
"func",
"Encode",
"(",
"providerName",
"[",
"]",
"byte",
",",
"params",
"string",
",",
"salt",
"[",
"]",
"byte",
",",
"key",
"[",
"]",
"byte",
")",
"(",
"res",
"[",
"]",
"byte",
")",
"{",
"salt64",
":=",
"encodeBase64",
"(",
"salt",
")",
"\n",
"k... | // Encode encodes given providerName, params, salt and key into Modular Crypt Format. | [
"Encode",
"encodes",
"given",
"providerName",
"params",
"salt",
"and",
"key",
"into",
"Modular",
"Crypt",
"Format",
"."
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/grypto/internal/mcf/mcf.go#L19-L32 |
19,683 | gramework/gramework | grypto/internal/mcf/mcf.go | encodeBase64 | func encodeBase64(in []byte) (out []byte) {
enc := base64.StdEncoding
out = make([]byte, enc.EncodedLen(len(in)))
enc.Encode(out, in)
return out
} | go | func encodeBase64(in []byte) (out []byte) {
enc := base64.StdEncoding
out = make([]byte, enc.EncodedLen(len(in)))
enc.Encode(out, in)
return out
} | [
"func",
"encodeBase64",
"(",
"in",
"[",
"]",
"byte",
")",
"(",
"out",
"[",
"]",
"byte",
")",
"{",
"enc",
":=",
"base64",
".",
"StdEncoding",
"\n",
"out",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"enc",
".",
"EncodedLen",
"(",
"len",
"(",
"in",
... | // encodeBase64 encodes the input bytes into standard base64. | [
"encodeBase64",
"encodes",
"the",
"input",
"bytes",
"into",
"standard",
"base64",
"."
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/grypto/internal/mcf/mcf.go#L35-L40 |
19,684 | gramework/gramework | grypto/internal/mcf/mcf.go | Decode | func Decode(mcf []byte, expectedPWType []byte) (providerName []byte, params string, salt []byte, key []byte, err error) {
if len(mcf) <= 1 || mcf[0] != Divider {
err = ErrorInvalidDecodeInput
return
}
parts := bytes.Split(mcf[1:], splitDivider)
if len(parts) != 4 {
err = ErrorInvalidDecodeInput
return
}
... | go | func Decode(mcf []byte, expectedPWType []byte) (providerName []byte, params string, salt []byte, key []byte, err error) {
if len(mcf) <= 1 || mcf[0] != Divider {
err = ErrorInvalidDecodeInput
return
}
parts := bytes.Split(mcf[1:], splitDivider)
if len(parts) != 4 {
err = ErrorInvalidDecodeInput
return
}
... | [
"func",
"Decode",
"(",
"mcf",
"[",
"]",
"byte",
",",
"expectedPWType",
"[",
"]",
"byte",
")",
"(",
"providerName",
"[",
"]",
"byte",
",",
"params",
"string",
",",
"salt",
"[",
"]",
"byte",
",",
"key",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"... | // Decode given MCF if it contains information about expected pw type | [
"Decode",
"given",
"MCF",
"if",
"it",
"contains",
"information",
"about",
"expected",
"pw",
"type"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/grypto/internal/mcf/mcf.go#L50-L85 |
19,685 | gramework/gramework | x/client/get.go | GET | func (client *Instance) GET() (statusCode int, body []byte, err error) {
api, err := client.nextServer()
if err != nil {
return 0, nil, err
}
return api.HostClient.Get(nil, api.Addr)
} | go | func (client *Instance) GET() (statusCode int, body []byte, err error) {
api, err := client.nextServer()
if err != nil {
return 0, nil, err
}
return api.HostClient.Get(nil, api.Addr)
} | [
"func",
"(",
"client",
"*",
"Instance",
")",
"GET",
"(",
")",
"(",
"statusCode",
"int",
",",
"body",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"api",
",",
"err",
":=",
"client",
".",
"nextServer",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // GET sends a request with GET method | [
"GET",
"sends",
"a",
"request",
"with",
"GET",
"method"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/x/client/get.go#L19-L26 |
19,686 | gramework/gramework | x/client/get.go | GetJSON | func (client *Instance) GetJSON(v interface{}) (statusCode int, err error) {
statusCode, body, err := client.GET()
if err != nil {
return 0, err
}
return statusCode, json.NewDecoder(bytes.NewReader(body)).Decode(&v)
} | go | func (client *Instance) GetJSON(v interface{}) (statusCode int, err error) {
statusCode, body, err := client.GET()
if err != nil {
return 0, err
}
return statusCode, json.NewDecoder(bytes.NewReader(body)).Decode(&v)
} | [
"func",
"(",
"client",
"*",
"Instance",
")",
"GetJSON",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"statusCode",
"int",
",",
"err",
"error",
")",
"{",
"statusCode",
",",
"body",
",",
"err",
":=",
"client",
".",
"GET",
"(",
")",
"\n",
"if",
"err",
... | // GetJSON sends a GET request and deserializes response in a provided variable | [
"GetJSON",
"sends",
"a",
"GET",
"request",
"and",
"deserializes",
"response",
"in",
"a",
"provided",
"variable"
] | 31c8d0b9955432cea19730996643bd857481d6a8 | https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/x/client/get.go#L29-L36 |
19,687 | natefinch/pie | pie.go | NewProvider | func NewProvider() Server {
return Server{
server: rpc.NewServer(),
rwc: rwCloser{os.Stdin, os.Stdout},
}
} | go | func NewProvider() Server {
return Server{
server: rpc.NewServer(),
rwc: rwCloser{os.Stdin, os.Stdout},
}
} | [
"func",
"NewProvider",
"(",
")",
"Server",
"{",
"return",
"Server",
"{",
"server",
":",
"rpc",
".",
"NewServer",
"(",
")",
",",
"rwc",
":",
"rwCloser",
"{",
"os",
".",
"Stdin",
",",
"os",
".",
"Stdout",
"}",
",",
"}",
"\n",
"}"
] | // NewProvider returns a Server that will serve RPC over this
// application's Stdin and Stdout. This method is intended to be run by the
// plugin application. | [
"NewProvider",
"returns",
"a",
"Server",
"that",
"will",
"serve",
"RPC",
"over",
"this",
"application",
"s",
"Stdin",
"and",
"Stdout",
".",
"This",
"method",
"is",
"intended",
"to",
"be",
"run",
"by",
"the",
"plugin",
"application",
"."
] | 9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9 | https://github.com/natefinch/pie/blob/9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9/pie.go#L18-L23 |
19,688 | natefinch/pie | pie.go | Close | func (s Server) Close() error {
if s.codec != nil {
return s.codec.Close()
}
return s.rwc.Close()
} | go | func (s Server) Close() error {
if s.codec != nil {
return s.codec.Close()
}
return s.rwc.Close()
} | [
"func",
"(",
"s",
"Server",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"s",
".",
"codec",
"!=",
"nil",
"{",
"return",
"s",
".",
"codec",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"return",
"s",
".",
"rwc",
".",
"Close",
"(",
")",
"\n",
"}"
] | // Close closes the connection with the client. If the client is a plugin
// process, the process will be stopped. Further communication using this
// Server will fail. | [
"Close",
"closes",
"the",
"connection",
"with",
"the",
"client",
".",
"If",
"the",
"client",
"is",
"a",
"plugin",
"process",
"the",
"process",
"will",
"be",
"stopped",
".",
"Further",
"communication",
"using",
"this",
"Server",
"will",
"fail",
"."
] | 9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9 | https://github.com/natefinch/pie/blob/9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9/pie.go#L36-L41 |
19,689 | natefinch/pie | pie.go | ServeCodec | func (s Server) ServeCodec(f func(io.ReadWriteCloser) rpc.ServerCodec) {
s.server.ServeCodec(f(s.rwc))
} | go | func (s Server) ServeCodec(f func(io.ReadWriteCloser) rpc.ServerCodec) {
s.server.ServeCodec(f(s.rwc))
} | [
"func",
"(",
"s",
"Server",
")",
"ServeCodec",
"(",
"f",
"func",
"(",
"io",
".",
"ReadWriteCloser",
")",
"rpc",
".",
"ServerCodec",
")",
"{",
"s",
".",
"server",
".",
"ServeCodec",
"(",
"f",
"(",
"s",
".",
"rwc",
")",
")",
"\n",
"}"
] | // ServeCodec starts the Server's RPC server, serving via the encoding returned
// by f. This call will block until the client hangs up. | [
"ServeCodec",
"starts",
"the",
"Server",
"s",
"RPC",
"server",
"serving",
"via",
"the",
"encoding",
"returned",
"by",
"f",
".",
"This",
"call",
"will",
"block",
"until",
"the",
"client",
"hangs",
"up",
"."
] | 9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9 | https://github.com/natefinch/pie/blob/9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9/pie.go#L51-L53 |
19,690 | natefinch/pie | pie.go | StartProvider | func StartProvider(output io.Writer, path string, args ...string) (*rpc.Client, error) {
pipe, err := start(makeCommand(output, path, args))
if err != nil {
return nil, err
}
return rpc.NewClient(pipe), nil
} | go | func StartProvider(output io.Writer, path string, args ...string) (*rpc.Client, error) {
pipe, err := start(makeCommand(output, path, args))
if err != nil {
return nil, err
}
return rpc.NewClient(pipe), nil
} | [
"func",
"StartProvider",
"(",
"output",
"io",
".",
"Writer",
",",
"path",
"string",
",",
"args",
"...",
"string",
")",
"(",
"*",
"rpc",
".",
"Client",
",",
"error",
")",
"{",
"pipe",
",",
"err",
":=",
"start",
"(",
"makeCommand",
"(",
"output",
",",
... | // StartProvider start a provider-style plugin application at the given path and
// args, and returns an RPC client that communicates with the plugin using gob
// encoding over the plugin's Stdin and Stdout. The writer passed to output
// will receive output from the plugin's stderr. Closing the RPC client
// returne... | [
"StartProvider",
"start",
"a",
"provider",
"-",
"style",
"plugin",
"application",
"at",
"the",
"given",
"path",
"and",
"args",
"and",
"returns",
"an",
"RPC",
"client",
"that",
"communicates",
"with",
"the",
"plugin",
"using",
"gob",
"encoding",
"over",
"the",
... | 9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9 | https://github.com/natefinch/pie/blob/9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9/pie.go#L82-L88 |
19,691 | natefinch/pie | pie.go | StartProviderCodec | func StartProviderCodec(
f func(io.ReadWriteCloser) rpc.ClientCodec,
output io.Writer,
path string,
args ...string,
) (*rpc.Client, error) {
pipe, err := start(makeCommand(output, path, args))
if err != nil {
return nil, err
}
return rpc.NewClientWithCodec(f(pipe)), nil
} | go | func StartProviderCodec(
f func(io.ReadWriteCloser) rpc.ClientCodec,
output io.Writer,
path string,
args ...string,
) (*rpc.Client, error) {
pipe, err := start(makeCommand(output, path, args))
if err != nil {
return nil, err
}
return rpc.NewClientWithCodec(f(pipe)), nil
} | [
"func",
"StartProviderCodec",
"(",
"f",
"func",
"(",
"io",
".",
"ReadWriteCloser",
")",
"rpc",
".",
"ClientCodec",
",",
"output",
"io",
".",
"Writer",
",",
"path",
"string",
",",
"args",
"...",
"string",
",",
")",
"(",
"*",
"rpc",
".",
"Client",
",",
... | // StartProviderCodec starts a provider-style plugin application at the given
// path and args, and returns an RPC client that communicates with the plugin
// using the ClientCodec returned by f over the plugin's Stdin and Stdout. The
// writer passed to output will receive output from the plugin's stderr.
// Closing t... | [
"StartProviderCodec",
"starts",
"a",
"provider",
"-",
"style",
"plugin",
"application",
"at",
"the",
"given",
"path",
"and",
"args",
"and",
"returns",
"an",
"RPC",
"client",
"that",
"communicates",
"with",
"the",
"plugin",
"using",
"the",
"ClientCodec",
"returne... | 9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9 | https://github.com/natefinch/pie/blob/9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9/pie.go#L96-L107 |
19,692 | natefinch/pie | pie.go | StartConsumer | func StartConsumer(output io.Writer, path string, args ...string) (Server, error) {
pipe, err := start(makeCommand(output, path, args))
if err != nil {
return Server{}, err
}
return Server{
server: rpc.NewServer(),
rwc: pipe,
}, nil
} | go | func StartConsumer(output io.Writer, path string, args ...string) (Server, error) {
pipe, err := start(makeCommand(output, path, args))
if err != nil {
return Server{}, err
}
return Server{
server: rpc.NewServer(),
rwc: pipe,
}, nil
} | [
"func",
"StartConsumer",
"(",
"output",
"io",
".",
"Writer",
",",
"path",
"string",
",",
"args",
"...",
"string",
")",
"(",
"Server",
",",
"error",
")",
"{",
"pipe",
",",
"err",
":=",
"start",
"(",
"makeCommand",
"(",
"output",
",",
"path",
",",
"arg... | // StartConsumer starts a consumer-style plugin application with the given path
// and args, writing its stderr to output. The plugin consumes an API this
// application provides. The function returns the Server for this host
// application, which should be used to register APIs for the plugin to consume. | [
"StartConsumer",
"starts",
"a",
"consumer",
"-",
"style",
"plugin",
"application",
"with",
"the",
"given",
"path",
"and",
"args",
"writing",
"its",
"stderr",
"to",
"output",
".",
"The",
"plugin",
"consumes",
"an",
"API",
"this",
"application",
"provides",
".",... | 9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9 | https://github.com/natefinch/pie/blob/9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9/pie.go#L113-L122 |
19,693 | natefinch/pie | pie.go | NewConsumer | func NewConsumer() *rpc.Client {
return rpc.NewClient(rwCloser{os.Stdin, os.Stdout})
} | go | func NewConsumer() *rpc.Client {
return rpc.NewClient(rwCloser{os.Stdin, os.Stdout})
} | [
"func",
"NewConsumer",
"(",
")",
"*",
"rpc",
".",
"Client",
"{",
"return",
"rpc",
".",
"NewClient",
"(",
"rwCloser",
"{",
"os",
".",
"Stdin",
",",
"os",
".",
"Stdout",
"}",
")",
"\n",
"}"
] | // NewConsumer returns an rpc.Client that will consume an API from the host
// process over this application's Stdin and Stdout using gob encoding. | [
"NewConsumer",
"returns",
"an",
"rpc",
".",
"Client",
"that",
"will",
"consume",
"an",
"API",
"from",
"the",
"host",
"process",
"over",
"this",
"application",
"s",
"Stdin",
"and",
"Stdout",
"using",
"gob",
"encoding",
"."
] | 9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9 | https://github.com/natefinch/pie/blob/9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9/pie.go#L126-L128 |
19,694 | natefinch/pie | pie.go | NewConsumerCodec | func NewConsumerCodec(f func(io.ReadWriteCloser) rpc.ClientCodec) *rpc.Client {
return rpc.NewClientWithCodec(f(rwCloser{os.Stdin, os.Stdout}))
} | go | func NewConsumerCodec(f func(io.ReadWriteCloser) rpc.ClientCodec) *rpc.Client {
return rpc.NewClientWithCodec(f(rwCloser{os.Stdin, os.Stdout}))
} | [
"func",
"NewConsumerCodec",
"(",
"f",
"func",
"(",
"io",
".",
"ReadWriteCloser",
")",
"rpc",
".",
"ClientCodec",
")",
"*",
"rpc",
".",
"Client",
"{",
"return",
"rpc",
".",
"NewClientWithCodec",
"(",
"f",
"(",
"rwCloser",
"{",
"os",
".",
"Stdin",
",",
"... | // NewConsumerCodec returns an rpc.Client that will consume an API from the host
// process over this application's Stdin and Stdout using the ClientCodec
// returned by f. | [
"NewConsumerCodec",
"returns",
"an",
"rpc",
".",
"Client",
"that",
"will",
"consume",
"an",
"API",
"from",
"the",
"host",
"process",
"over",
"this",
"application",
"s",
"Stdin",
"and",
"Stdout",
"using",
"the",
"ClientCodec",
"returned",
"by",
"f",
"."
] | 9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9 | https://github.com/natefinch/pie/blob/9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9/pie.go#L133-L135 |
19,695 | natefinch/pie | pie.go | start | func start(cmd commander) (_ ioPipe, err error) {
in, err := cmd.StdinPipe()
if err != nil {
return ioPipe{}, err
}
defer func() {
if err != nil {
in.Close()
}
}()
out, err := cmd.StdoutPipe()
if err != nil {
return ioPipe{}, err
}
defer func() {
if err != nil {
out.Close()
}
}()
proc, err... | go | func start(cmd commander) (_ ioPipe, err error) {
in, err := cmd.StdinPipe()
if err != nil {
return ioPipe{}, err
}
defer func() {
if err != nil {
in.Close()
}
}()
out, err := cmd.StdoutPipe()
if err != nil {
return ioPipe{}, err
}
defer func() {
if err != nil {
out.Close()
}
}()
proc, err... | [
"func",
"start",
"(",
"cmd",
"commander",
")",
"(",
"_",
"ioPipe",
",",
"err",
"error",
")",
"{",
"in",
",",
"err",
":=",
"cmd",
".",
"StdinPipe",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ioPipe",
"{",
"}",
",",
"err",
"\n",
"}... | // start runs the plugin and returns an ioPipe that can be used to control the
// plugin. | [
"start",
"runs",
"the",
"plugin",
"and",
"returns",
"an",
"ioPipe",
"that",
"can",
"be",
"used",
"to",
"control",
"the",
"plugin",
"."
] | 9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9 | https://github.com/natefinch/pie/blob/9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9/pie.go#L139-L164 |
19,696 | natefinch/pie | pie.go | Close | func (iop ioPipe) Close() error {
err := iop.ReadCloser.Close()
if writeErr := iop.WriteCloser.Close(); writeErr != nil {
err = writeErr
}
if procErr := iop.closeProc(); procErr != nil {
err = procErr
}
return err
} | go | func (iop ioPipe) Close() error {
err := iop.ReadCloser.Close()
if writeErr := iop.WriteCloser.Close(); writeErr != nil {
err = writeErr
}
if procErr := iop.closeProc(); procErr != nil {
err = procErr
}
return err
} | [
"func",
"(",
"iop",
"ioPipe",
")",
"Close",
"(",
")",
"error",
"{",
"err",
":=",
"iop",
".",
"ReadCloser",
".",
"Close",
"(",
")",
"\n",
"if",
"writeErr",
":=",
"iop",
".",
"WriteCloser",
".",
"Close",
"(",
")",
";",
"writeErr",
"!=",
"nil",
"{",
... | // Close closes the pipe's WriteCloser, ReadClosers, and process. | [
"Close",
"closes",
"the",
"pipe",
"s",
"WriteCloser",
"ReadClosers",
"and",
"process",
"."
] | 9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9 | https://github.com/natefinch/pie/blob/9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9/pie.go#L212-L221 |
19,697 | natefinch/pie | pie.go | closeProc | func (iop ioPipe) closeProc() error {
result := make(chan error, 1)
go func() { _, err := iop.proc.Wait(); result <- err }()
if err := iop.proc.Signal(os.Interrupt); err != nil {
return err
}
select {
case err := <-result:
return err
case <-time.After(procTimeout):
if err := iop.proc.Kill(); err != nil {
... | go | func (iop ioPipe) closeProc() error {
result := make(chan error, 1)
go func() { _, err := iop.proc.Wait(); result <- err }()
if err := iop.proc.Signal(os.Interrupt); err != nil {
return err
}
select {
case err := <-result:
return err
case <-time.After(procTimeout):
if err := iop.proc.Kill(); err != nil {
... | [
"func",
"(",
"iop",
"ioPipe",
")",
"closeProc",
"(",
")",
"error",
"{",
"result",
":=",
"make",
"(",
"chan",
"error",
",",
"1",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"_",
",",
"err",
":=",
"iop",
".",
"proc",
".",
"Wait",
"(",
")",
";",
"re... | // closeProc sends an interrupt signal to the pipe's process, and if it doesn't
// respond in one second, kills the process. | [
"closeProc",
"sends",
"an",
"interrupt",
"signal",
"to",
"the",
"pipe",
"s",
"process",
"and",
"if",
"it",
"doesn",
"t",
"respond",
"in",
"one",
"second",
"kills",
"the",
"process",
"."
] | 9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9 | https://github.com/natefinch/pie/blob/9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9/pie.go#L229-L244 |
19,698 | natefinch/pie | pie.go | Close | func (rw rwCloser) Close() error {
err := rw.ReadCloser.Close()
if err := rw.WriteCloser.Close(); err != nil {
return err
}
return err
} | go | func (rw rwCloser) Close() error {
err := rw.ReadCloser.Close()
if err := rw.WriteCloser.Close(); err != nil {
return err
}
return err
} | [
"func",
"(",
"rw",
"rwCloser",
")",
"Close",
"(",
")",
"error",
"{",
"err",
":=",
"rw",
".",
"ReadCloser",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
":=",
"rw",
".",
"WriteCloser",
".",
"Close",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
... | // Close closes both the ReadCloser and the WriteCloser, returning the last
// error from either. | [
"Close",
"closes",
"both",
"the",
"ReadCloser",
"and",
"the",
"WriteCloser",
"returning",
"the",
"last",
"error",
"from",
"either",
"."
] | 9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9 | https://github.com/natefinch/pie/blob/9a0d7201400759b777f38c0c2d7b0be4e3e8b5c9/pie.go#L254-L260 |
19,699 | awalterschulze/goderive | derive/fields.go | Name | func (f *Field) Name(recv string, unsafePkg Import) string {
if !f.Private() || !f.external {
return recv + "." + f.name
}
return `*(*` + f.typeStr() + `)(` + unsafePkg() + `.Pointer(` + recv + `.FieldByName("` + f.name + `").UnsafeAddr()))`
} | go | func (f *Field) Name(recv string, unsafePkg Import) string {
if !f.Private() || !f.external {
return recv + "." + f.name
}
return `*(*` + f.typeStr() + `)(` + unsafePkg() + `.Pointer(` + recv + `.FieldByName("` + f.name + `").UnsafeAddr()))`
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"Name",
"(",
"recv",
"string",
",",
"unsafePkg",
"Import",
")",
"string",
"{",
"if",
"!",
"f",
".",
"Private",
"(",
")",
"||",
"!",
"f",
".",
"external",
"{",
"return",
"recv",
"+",
"\"",
"\"",
"+",
"f",
"."... | // Name returns the field name, given the receiver and the unsafe import, if needed. | [
"Name",
"returns",
"the",
"field",
"name",
"given",
"the",
"receiver",
"and",
"the",
"unsafe",
"import",
"if",
"needed",
"."
] | 71608c676057f3512b43cbd61d645b0dc6bcfc20 | https://github.com/awalterschulze/goderive/blob/71608c676057f3512b43cbd61d645b0dc6bcfc20/derive/fields.go#L37-L42 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.