id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c8800
{ for _, log := range l.loggers { log.Debugf(format, v...) } }
c8801
{ for _, log := range l.loggers { log.Debug(v...) } }
c8802
{ for _, log := range l.loggers { log.Info(v...) } }
c8803
{ for _, log := range l.loggers { log.Warn(v...) } }
c8804
{ for _, log := range l.loggers { log.Error(v...) } }
c8805
l.SetOutputLevel(log.Ldebug) return l }
c8806
if l, ok := action.(LogInterface); ok { l.SetLogger(ctx.Logger) } } ctx.Next() if !ctx.Written() { if ctx.Result == nil { ctx.Result = NotFound() } ctx.HandleError() } statusCode := ctx.Status() if statusCode >= 200 && statusCode < 400 { ctx.Info(ctx.Req().Method, statusCode, tim...
c8807
{ return (*http.Request)(f).URL.Query() }
c8808
(*Queries)(ctx.req).MustString(key, defaults...) }
c8809
(*Queries)(ctx.req).MustStrings(key, defaults...) }
c8810
return (*Queries)(ctx.req).MustEscape(key, defaults...) }
c8811
return (*Queries)(ctx.req).MustInt(key, defaults...) }
c8812
return (*Queries)(ctx.req).MustInt32(key, defaults...) }
c8813
return (*Queries)(ctx.req).MustInt64(key, defaults...) }
c8814
return (*Queries)(ctx.req).MustUint(key, defaults...) }
c8815
return (*Queries)(ctx.req).MustUint32(key, defaults...) }
c8816
return (*Queries)(ctx.req).MustUint64(key, defaults...) }
c8817
(*Queries)(ctx.req).MustFloat32(key, defaults...) }
c8818
...Handler) { t.Route([]string{"GET", "HEAD:Get"}, url, c, middlewares...) }
c8819
middlewares...) t.Route([]string{"HEAD:Get"}, url, c, middlewares...) }
c8820
append(t.handlers, handlers...) }
c8821
{ host = envHost } else if len(host) == 0 { host = "0.0.0.0" } if envPort, _ := strconv.ParseInt(os.Getenv("PORT"), 10, 32); envPort != 0 { port = int(envPort) } else if port == 0 { port = 8000 } addr := host + ":" + strconv.FormatInt(int64(port), 10) return addr }
c8822
https://" + addr) t.Server.Addr = addr t.Server.Handler = t err := t.ListenAndServeTLS(certFile, keyFile) if err != nil { t.logger.Error(err) } }
c8823
handler.ServeHTTP(ctx.ResponseWriter, ctx.Req()) ctx.Next() } }
c8824
http.Handler) { t.Use(WrapBefore(handler)) }
c8825
tan: tan, Logger: tan.logger, } } tan.respPool.New = func() interface{} { return &responseWriter{} } tan.Use(handlers...) return tan }
c8826
= l[0] } return NewWithLog( logger, ClassicHandlers..., ) }
c8827
*Context) { ctx.ServeFile(path) } }
c8828
len(*params) <= 0 { ctx.Result = NotFound() ctx.HandleError() return } ctx.ServeFile(filepath.Join(dir, (*params)[0].Value)) } }
c8829
<< 20) if v, ok := (*http.Request)(f).Form[key]; ok { return v, nil } return nil, errors.New("not exist") }
c8830
(*Forms)(ctx.req).MustString(key, defaults...) }
c8831
(*Forms)(ctx.req).MustStrings(key, defaults...) }
c8832
return (*Forms)(ctx.req).MustEscape(key, defaults...) }
c8833
return (*Forms)(ctx.req).MustInt(key, defaults...) }
c8834
return (*Forms)(ctx.req).MustInt32(key, defaults...) }
c8835
return (*Forms)(ctx.req).MustInt64(key, defaults...) }
c8836
return (*Forms)(ctx.req).MustUint(key, defaults...) }
c8837
return (*Forms)(ctx.req).MustUint32(key, defaults...) }
c8838
return (*Forms)(ctx.req).MustUint64(key, defaults...) }
c8839
return (*Forms)(ctx.req).MustFloat32(key, defaults...) }
c8840
&secureCookies{ (*cookies)(ctx), secret, } }
c8841
} ip := strings.Split(ctx.Req().RemoteAddr, ":") if len(ip) > 0 { if ip[0] != "[" { return ip[0] } } return "127.0.0.1" }
c8842
return io.WriteString(ctx.ResponseWriter, content) }
c8843
return ctx.ServeContent(file, http.Dir(dir)) }
c8844
http.Error(ctx, http.StatusText(http.StatusForbidden), http.StatusForbidden) return nil } http.ServeContent(ctx, ctx.Req(), d.Name(), d.ModTime(), f) return nil }
c8845
:= encoder.Encode(obj) if err != nil { ctx.Header().Del("Content-Type") } return err }
c8846
:= encoder.Encode(obj) if err != nil { ctx.Header().Del("Content-Type") } return err }
c8847
if err != nil { return nil, err } ctx.req.Body.Close() ctx.req.Body = ioutil.NopCloser(bytes.NewBuffer(body)) return body, nil }
c8848
return err } return json.Unmarshal(body, obj) }
c8849
return err } return xml.Unmarshal(body, obj) }
c8850
f.Close() fName := filepath.Base(fpath) ctx.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%v\"", fName)) _, err = io.Copy(ctx, f) return err }
c8851
err := os.OpenFile(savePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666) if err != nil { return err } defer f.Close() _, err = io.Copy(f, file) return err }
c8852
= status[0] } http.Redirect(ctx.ResponseWriter, ctx.Req(), url, s) }
c8853
http.StatusText(http.StatusUnauthorized)) }
c8854
http.StatusText(http.StatusNotFound)) return } ctx.Abort(http.StatusNotFound, message[0]) }
c8855
ok := action.(Contexter); ok { a.SetContext(ctx) } } ctx.Next() } }
c8856
} return &abortError{code, http.StatusText(code)} }
c8857
ctx.WriteHeader(http.StatusInternalServerError) ctx.WriteString(http.StatusText(http.StatusInternalServerError)) } } }
c8858
if rext == ext { return true } } return false }
c8859
&Route{ raw: v, routeType: tp, method: method, pool: pool, handlers: handlers, } }
c8860
r.routeType == StructPtrRoute }
c8861
} return true } if e[j].tp == snode { return false } return i < j }
c8862
{ r.trees[m] = &node{ edges: edges{}, } } return }
c8863
r.matchNode(n, url, params) if e != nil { return e.handle, newParams } } return nil, nil }
c8864
for _, node := range nodes[1:] { if lastTp.tp != snode && node.tp != snode { return false } lastTp = node } return true }
c8865
:= 0; i < len(nodes); i++ { p = r.addnode(p, nodes, i) } }
c8866
} else { panic("unknow methods format") } case []string: for _, m := range ms.([]string) { s := strings.Split(m, ":") if len(s) == 1 { methods[s[0]] = strings.Title(strings.ToLower(s[0])) } else if len(s) == 2 { methods[s[0]] = strings.TrimSpace(s[1]) } else { panic("unknow ...
c8867
"auto") return } } if action := ctx.Action(); action != nil { if c, ok := action.(Compresser); ok { compress(ctx, c.CompressType()) return } } // if blank, then no compress ctx.Next() } }
c8868
break } else { fmt.Fprintf(&buf, "\n") } fmt.Fprintf(&buf, "%v:%v", file, line) } var content = buf.String() ctx.Logger.Error(content) if !ctx.Written() { if !debug { ctx.Result = InternalServerError(http.StatusText(http.StatusInternalServerError)) } else { ...
c8869
for _, v := range *p { if v.Name == key { return v.Value } } return "" }
c8870
{ key = ":" + key } var s = make([]string, 0) for _, v := range *p { if v.Name == key { s = append(s, v.Value) } } if len(s) > 0 { return s, nil } return nil, errors.New("not exist") }
c8871
_, v := range *p { if v.Name == key { return v.Value } } if len(defaults) > 0 { return defaults[0] } return "" }
c8872
append(s, v.Value) } } if len(s) > 0 { return s } if len(defaults) > 0 { return defaults[0] } return []string{} }
c8873
ctx.Params().MustString(key, defaults...) }
c8874
return ctx.Params().MustStrings(key, defaults...) }
c8875
return ctx.Params().MustEscape(key, defaults...) }
c8876
return ctx.Params().MustInt(key, defaults...) }
c8877
return ctx.Params().MustInt32(key, defaults...) }
c8878
return ctx.Params().MustInt64(key, defaults...) }
c8879
return ctx.Params().MustUint(key, defaults...) }
c8880
return ctx.Params().MustUint32(key, defaults...) }
c8881
return ctx.Params().MustUint64(key, defaults...) }
c8882
return ctx.Params().MustFloat32(key, defaults...) }
c8883
return ctx.Params().MustFloat64(key, defaults...) }
c8884
return ctx.Params().MustBool(key, defaults...) }
c8885
ok := action.(Paramer); ok { p.SetParams(*ctx.Params()) } } ctx.Next() } }
c8886
append(g.handlers, handlers...) }
c8887
...Handler) { g.Route([]string{"GET", "HEAD:Get"}, url, c, middlewares...) }
c8888
middlewares...) g.Route([]string{"HEAD:Get"}, url, c, middlewares...) }
c8889
g.routers = append(g.routers, groupRouter{methods, url, c, middlewares}) }
c8890
g.Route(gchild.methods, joinRoute(p, gchild.url), gchild.c, append(gr.handlers, gchild.handlers...)...) } }
c8891
t.addGroup(p, getGroup(o)) }
c8892
:= g.checkIDExist(migrationID); err != nil { return err } return g.migrate(migrationID) }
c8893
!= nil || len(g.migrations) > 0 }
c8894
return &ReservedIDError{ID: m.ID} } } return nil }
c8895
:= g.migrationRan(migration) if err != nil { return err } if migrationRan { if err := g.rollbackMigration(migration); err != nil { return err } } } return g.commit() }
c8896
the ID doesn't exist, we also want the list of migrations to be empty var count int err = g.tx. Table(g.options.TableName). Count(&count). Error return count == 0, err }
c8897
just called") } callInfo := struct { }{} lockMyInterfaceMockOne.Lock() mock.calls.One = append(mock.calls.One, callInfo) lockMyInterfaceMockOne.Unlock() return mock.OneFunc() }
c8898
just called") } callInfo := struct { }{} lockMyInterfaceMockThree.Lock() mock.calls.Three = append(mock.calls.Three, callInfo) lockMyInterfaceMockThree.Unlock() return mock.ThreeFunc() }
c8899
just called") } callInfo := struct { }{} lockMyInterfaceMockTwo.Lock() mock.calls.Two = append(mock.calls.Two, callInfo) lockMyInterfaceMockTwo.Unlock() return mock.TwoFunc() }