id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c19600 | nil {
r.httprouter = &Router{
router: newRouter(),
app: r.app,
root: r,
}
}
r.mu.Unlock()
return r.httprouter
} | |
c19601 | nil {
r.httpsrouter = &Router{
router: newRouter(),
app: r.app,
root: r,
}
}
r.mu.Unlock()
return r.httpsrouter
} | |
c19602 | x >= 1024; x = x / 1024 {
suff++
}
return fmt.Sprintf("%.2f%s", x, suff.String())
} | |
c19603 | m runtime.MemStats
runtime.ReadMemStats(&m)
e := ctx.JSON(m)
_ = e
} | |
c19604 | i.Lock.Lock()
if i.Services[serviceName].Addresses == nil {
i.Services[serviceName].Addresses = make([]Address, 0)
}
i.UpdateTimestamp = time.Now().UnixNano()
i.Services[serviceName].Addresses = append(i.Services[serviceName].Addresses, addr)
i.Lock.Unlock()
return nil
} | |
c19605 | },
},
[]string{"code", "method", "path", "type"},
)
if err = prometheus.Register(m.httpReqCounter); err != nil {
return err
}
m.reqDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: "gramework_http_requests_duration_seconds",
Help: "Request processing duration, partitioned by co... | |
c19606 | {
if d != 0 {
app.cookieExpire = d
}
} | |
c19607 | {
if newPolicy != nil {
app.sanitizerPolicy = newPolicy
}
} | |
c19608 | }
app.runningServers = newRunningList
if err == nil {
app.internalLog.Warn("application servers shutted down successfully")
return
}
app.internalLog.WithError(err).WithField("stillRunning", len(app.runningServers)).Warn("could not stop servers")
return
} | |
c19609 | DefaultAkamaiIPHeader,
}
for _, opt := range opts {
opt(a)
}
return a
} | |
c19610 | i := 0; i < len(s); i++ {
c := s[i]
if c >= 'A' && c <= 'Z' {
c += 'a' - 'A'
}
b.WriteByte(c)
}
return b.String()
}
return stringsMap(unicode.ToLower, s)
} | |
c19611 | }
s = s[i:]
break
}
// Fast path for unchanged input
if b.Cap() == 0 { // didn't call b.Grow above
return s
}
for _, c := range s {
r := mapping(c)
if r >= 0 {
// common case
// Due to inlining, it is more performant to determine if WriteByte should be
// invoked rather than always call Wri... | |
c19612 | {
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
} | |
c19613 | ok {
i.Services[name].Addresses = append(i.Services[name].Addresses, s.Addresses...)
i.Lock.Unlock()
return
}
i.Services[name] = &s
i.Lock.Unlock()
} | |
c19614 |
if e == PROD {
Logger.Level = log.InfoLevel
enableDebug = false
} else {
enableDebug = true
Logger.Level = log.DebugLevel
}
atomic.StoreInt32(currentEnvironment, int32(e))
} | |
c19615 | if err != nil {
app.internalLog.Errorf("Can't get cert for %q: %s", hello.ServerName, err)
}
return cert, err
}
tlsLn := tls.NewListener(ln, tlsConfig)
l := app.internalLog.WithField("bind", addr)
l.Info("Starting HTTPS")
srv := app.copyServer()
app.runningServersMu.Lock()
app.runningServers = append... | |
c19616 |
tableBuilder: tb,
name: name,
}
} | |
c19617 | *CreateTableBuilder {
tb.columns = append(tb.columns, *c)
return tb
} | |
c19618 | clientsMu: new(sync.RWMutex),
balancer: newRangeBalancer(),
}
return client
} | |
c19619 |
p.r == p1.r &&
p.p == p1.p &&
p.saltLen == p1.saltLen
} | |
c19620 | fmt.Sprintf(paramsFmt, p.keyLen, p.n, p.r, p.p, p.saltLen)
} | |
c19621 | DefaultR,
p: DefaultP,
saltLen: DefaultSaltLen,
},
}
} | |
c19622 | return p.Hash([]byte(plaintext))
} | |
c19623 | }
switch sentType {
case jsonCT:
err = ctx.JSON(v)
case xmlCT:
err = ctx.XML(v)
case csvCT:
err = ctx.CSV(v)
}
return sentType, err
} | |
c19624 | e := ctx.WriteString(src[0])
_ = e
}
return ctx
} | |
c19625 |
ctx.Response.Header.Set(corsAccessControlAllowMethods, methods)
ctx.Response.Header.Set(corsAccessControlAllowHeaders, corsCType)
ctx.Response.Header.Set(corsAccessControlAllowCredentials, trueStr)
return ctx
} | |
c19626 | nil {
return err
}
_, err = ctx.Write(b)
return err
} | |
c19627 | ctx.Logger.WithError(err).Error("Err500 serving error")
}
case error:
_, e := ctx.Writef(fmtS, v)
_ = e // it's already 500
default:
_, e := ctx.Writef(fmtV, v)
_ = e
}
}
return ctx
} | |
c19628 | error {
ctx.Err500()
return ctx.JSON(v)
} | |
c19629 | false
}
return p.Valid(hash, password)
} | |
c19630 | assertAppNotNill(app)
app.name = n
}
} | |
c19631 | {
return func(app *App) {
assertAppNotNill(app)
app.Logger = logger
}
} | |
c19632 | if s == nil {
panic(errors.New("cannot set nil as app server instance"))
}
app.serverBase = s
app.serverBase.Handler = app.handler()
}
} | |
c19633 | app.serverBase = newDefaultServerBaseFor(app)
}
app.serverBase.MaxRequestBodySize = size
}
} | |
c19634 | app.serverBase = newDefaultServerBaseFor(app)
}
app.serverBase.KeepHijackedConns = keep
}
} | |
c19635 | name: cb.name,
sqlType: "INTEGER",
})
} | |
c19636 | methodToIdx(GET): make(map[string]staticHandler),
methodToIdx(DELETE): make(map[string]staticHandler),
methodToIdx(HEAD): make(map[string]staticHandler),
methodToIdx(OPTIONS): make(map[string]staticHandler),
methodToIdx(PATCH): make(map[string]staticHandler),
methodToIdx(POST): make(map[string]... | |
c19637 | != nil {
tracer.WithFields(log.Fields{
"reason": rcv,
"code": ctx.Response.StatusCode(),
}).Error("request caused panic")
}
}
} | |
c19638 | {
return string(ctx.Request.Header.Peek(contentType))
} | |
c19639 | if err != nil {
return emptyString
}
return v
} | |
c19640 |
b := bytes.NewBuffer(nil)
err := xml.NewEncoder(b).Encode(v)
return b.Bytes(), err
} | |
c19641 |
return emptyString, ErrArgNotFound
}
switch value := i.(type) {
case string:
return value, nil
default:
return fmt.Sprintf(fmtV, i), nil
}
} | |
c19642 |
u.SetScheme(https)
ctx.Redirect(u.String(), redirectCode)
} | |
c19643 | ffjson.NewEncoder(b)
err := enc.Encode(v)
return b.Bytes(), err
} | |
c19644 | {
return ffjson.NewDecoder().Decode(ctx.Request.Body(), &v)
} | |
c19645 | len(ctx.Cookies.Storage) > 0 {
return false
}
return true
},
CacheKey: func(ctx *Context) []byte {
return ctx.Path()
},
}
} | |
c19646 | v := <-client.watch(ctx)
err := conn.WriteMessage(websocket.TextMessage, v)
if err != nil {
break
}
}
})
}
return client.handleHTTP(ctx)
}
} | |
c19647 | path,
toLower(path),
make([]byte, zero, len(path)+one), // preallocate enough memory for new path
[4]byte{}, // empty rune buffer
fixTrailingSlash,
)
} | |
c19648 | name,
columns: make([]tableColumn, 0),
}
} | |
c19649 | nil {
app.domains[domain] = &Router{
router: newRouter(),
app: app,
}
}
app.domainListLock.Unlock()
return app.domains[domain]
} | |
c19650 | app.ServeDirCustom(path, 0, true, false, []string{"index.html", "index.htm"})
} | |
c19651 |
CacheDuration: 5 * time.Minute,
CompressedFileSuffix: ".gz",
}
if stripSlashes > 0 {
fs.PathRewrite = fasthttp.NewPathSlashesStripper(stripSlashes)
}
h := fs.NewRequestHandler()
return func(ctx *Context) {
h(ctx.RequestCtx)
}
} | |
c19652 | {
return app.ServeDirNoCacheCustom(path, 0, true, false, nil)
} | |
c19653 |
pragmaH := "Pragma"
pragmaV := "no-cache"
expiresH := "Expires"
expiresV := "0"
ccH := "Cache-Control"
ccV := "no-cache, no-store, must-revalidate"
return func(ctx *Context) {
ctx.Response.Header.Add(pragmaH, pragmaV)
ctx.Response.Header.Add(expiresH, expiresV)
ctx.Response.Header.Add(ccH, ccV)
h(ctx.Re... | |
c19654 |
app.flagsQueue = append(app.flagsQueue, f)
} | |
c19655 | v.Name,
Description: v.Description,
Default: v.Default,
Value: flag.String(v.Name, v.Default, v.Description),
}
}
} | |
c19656 | if bindFlag, ok := app.Flags.values[name]; ok {
return *bindFlag.Value, ok
}
}
return "", false
} | |
c19657 | {
app.middlewares = append(app.middlewares, processor)
}
app.middlewaresMu.Unlock()
return err
} | |
c19658 |
app.preMiddlewares = append(app.preMiddlewares, processor)
}
app.preMiddlewaresMu.Unlock()
return err
} | |
c19659 | app.middlewaresAfterRequest = append(app.middlewaresAfterRequest, processor)
}
app.middlewaresAfterRequestMu.Unlock()
return nil
} | |
c19660 | ctx.Logger.Debugf("%s = [%s]\n", k, v)
})
} | |
c19661 | err = fasthttp.Do(proxyReq, &ctx.Response)
fasthttp.ReleaseRequest(proxyReq)
return
} | |
c19662 | {
return doReg(r, collectors, true, true)
} | |
c19663 | error {
return doReg(r, collectors, false, true)
} | |
c19664 | make(map[string]*Service),
UpdateTimestamp: time.Now().UnixNano(),
}
} | |
c19665 |
if err != nil {
return false
}
max, err := strconv.Atoi(portRange[1])
if err != nil {
return false
}
for _, p := range allowedPortsInts {
if min <= p && max >= p {
return true
}
}
return false
}
for _, p := range allowedPorts {
if port == p {
return true
}
}
return false
} | |
c19666 | fmt.Sprintln(`INSERT INTO`, table),
lock: new(sync.Mutex),
}
} | |
c19667 | Insert(table)
i.prepared = true
return i
} | |
c19668 | len(columns)-1 {
b.query = fmt.Sprintf(`%s,`, b.query)
}
}
b.query = fmt.Sprintf(`%s)`, b.query)
b.lock.Unlock()
return b
} | |
c19669 |
}
}
} else {
for k := range columnValues {
sqlValue = fmt.Sprintf("%s?", sqlValue)
if k < len(columnValues)-1 {
sqlValue = fmt.Sprintf("%s, ", sqlValue)
}
}
}
b.sqlValues = append(b.sqlValues, fmt.Sprintf(`%s)`, sqlValue))
b.lock.Unlock()
return b
} | |
c19670 |
return fmt.Sprintf("%s\n VALUES %s;", b.query, strings.Join(b.sqlValues, ", \n "))
} | |
c19671 |
ctx.Logger.WithError(err).WithField("package", "mw/graphiql").Error("could not send template")
}
} | |
c19672 | ctx.App.cookieDomain, len(ctx.App.cookieDomain) > 0
} | |
c19673 | == nil {
c.Storage = make(map[string]string, zero)
}
c.Storage[key] = value
c.Mu.Unlock()
} | |
c19674 |
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
} | |
c19675 |
c.Mu.Unlock()
return false
}
if _, ok := c.Storage[key]; ok {
c.Mu.Unlock()
return ok
}
c.Mu.Unlock()
return false
} | |
c19676 | Expected *SubRouter or *Router, got %T! Returning nil!", parent)
Errorf("Please report the bug on https://github.com/gramework/gramework ASAP!")
return nil
}
} | |
c19677 | Expected *SubRouter or *Router, got %T! Returning nil!", parent)
Errorf("Please report the bug on https://github.com/gramework/gramework ASAP!")
return nil
}
} | |
c19678 | }
}
return r, nil
}
ctSplitParams := strings.Split(ctx.ContentType(), delimiterCTParams)
switch ctSplitParams[0] {
case jsonCTshort:
if err := ctx.UnJSON(&r); err != nil {
return nil, err
}
case gqlCT:
r.Query = string(ctx.PostBody())
}
return r, nil
} | |
c19679 |
if fw.isBlocked(remoteAddr) {
return true, remoteAddr
}
// Register the new request in a new goroutine
go fw.addRequest(remoteAddr)
return false, remoteAddr
} | |
c19680 |
_, exists := fw.blockList[remoteAddr]
fw.blockListMutex.Unlock()
return exists
} | |
c19681 | app.Logger.WithError(err).WithField("package", "mw/xhostname").Error("could not register middleware")
}
} | |
c19682 | providerName...)
res = append(res, Divider)
res = append(res, params...)
res = append(res, Divider)
res = append(res, salt64...)
res = append(res, Divider)
res = append(res, key64...)
return res
} | |
c19683 | enc.EncodedLen(len(in)))
enc.Encode(out, in)
return out
} | |
c19684 | return
}
if subtle.ConstantTimeCompare(parts[0], expectedPWType) == 0 {
err = ErrorInvalidDecodeInput
return
}
params = string(parts[1])
saltDecoded, err := decodeBase64(parts[2])
if err != nil {
err = ErrorInvalidDecodeInput
return
}
salt = saltDecoded
keyDecoded, err := decodeBase64(parts[3])
... | |
c19685 |
return 0, nil, err
}
return api.HostClient.Get(nil, api.Addr)
} | |
c19686 |
return statusCode, json.NewDecoder(bytes.NewReader(body)).Decode(&v)
} | |
c19687 | rpc.NewServer(),
rwc: rwCloser{os.Stdin, os.Stdout},
}
} | |
c19688 | return s.codec.Close()
}
return s.rwc.Close()
} | |
c19689 | rpc.ServerCodec) {
s.server.ServeCodec(f(s.rwc))
} | |
c19690 | if err != nil {
return nil, err
}
return rpc.NewClient(pipe), nil
} | |
c19691 | path, args))
if err != nil {
return nil, err
}
return rpc.NewClientWithCodec(f(pipe)), nil
} | |
c19692 | return Server{}, err
}
return Server{
server: rpc.NewServer(),
rwc: pipe,
}, nil
} | |
c19693 | rpc.NewClient(rwCloser{os.Stdin, os.Stdout})
} | |
c19694 | rpc.NewClientWithCodec(f(rwCloser{os.Stdin, os.Stdout}))
} | |
c19695 | out.Close()
}
}()
proc, err := cmd.Start()
if err != nil {
return ioPipe{}, err
}
return ioPipe{out, in, proc}, nil
} | |
c19696 |
}
if procErr := iop.closeProc(); procErr != nil {
err = procErr
}
return err
} | |
c19697 | return err
case <-time.After(procTimeout):
if err := iop.proc.Kill(); err != nil {
return fmt.Errorf("error killing process after timeout: %s", err)
}
return errProcStopTimeout
}
} | |
c19698 | rw.WriteCloser.Close(); err != nil {
return err
}
return err
} | |
c19699 | + "." + f.name
}
return `*(*` + f.typeStr() + `)(` + unsafePkg() + `.Pointer(` + recv + `.FieldByName("` + f.name + `").UnsafeAddr()))`
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.