id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
149,400
libkermit/compose
compose.go
Start
func (p *Project) Start(services ...string) error { // If project chan are closed, recreate new compose project if !p.hasOpenedChan { newProject, _ := CreateProject(p.name, p.composeFiles...) *p = *newProject } ctx := context.Background() err := p.composeProject.Create(ctx, options.Create{}, services...) if e...
go
func (p *Project) Start(services ...string) error { // If project chan are closed, recreate new compose project if !p.hasOpenedChan { newProject, _ := CreateProject(p.name, p.composeFiles...) *p = *newProject } ctx := context.Background() err := p.composeProject.Create(ctx, options.Create{}, services...) if e...
[ "func", "(", "p", "*", "Project", ")", "Start", "(", "services", "...", "string", ")", "error", "{", "// If project chan are closed, recreate new compose project", "if", "!", "p", ".", "hasOpenedChan", "{", "newProject", ",", "_", ":=", "CreateProject", "(", "p"...
// Start creates and starts the compose project.
[ "Start", "creates", "and", "starts", "the", "compose", "project", "." ]
c04e39c026ad1c76c027d6780150c8f7dec0a610
https://github.com/libkermit/compose/blob/c04e39c026ad1c76c027d6780150c8f7dec0a610/compose.go#L84-L97
149,401
libkermit/compose
compose.go
StartOnly
func (p *Project) StartOnly(services ...string) error { ctx := context.Background() err := p.composeProject.Start(ctx, services...) if err != nil { return err } // Wait for compose to start <-p.started return nil }
go
func (p *Project) StartOnly(services ...string) error { ctx := context.Background() err := p.composeProject.Start(ctx, services...) if err != nil { return err } // Wait for compose to start <-p.started return nil }
[ "func", "(", "p", "*", "Project", ")", "StartOnly", "(", "services", "...", "string", ")", "error", "{", "ctx", ":=", "context", ".", "Background", "(", ")", "\n", "err", ":=", "p", ".", "composeProject", ".", "Start", "(", "ctx", ",", "services", "....
// StartOnly only starts created services which are stopped.
[ "StartOnly", "only", "starts", "created", "services", "which", "are", "stopped", "." ]
c04e39c026ad1c76c027d6780150c8f7dec0a610
https://github.com/libkermit/compose/blob/c04e39c026ad1c76c027d6780150c8f7dec0a610/compose.go#L100-L109
149,402
libkermit/compose
compose.go
StopOnly
func (p *Project) StopOnly(services ...string) error { ctx := context.Background() err := p.composeProject.Stop(ctx, 10, services...) if err != nil { return err } <-p.stopped return nil }
go
func (p *Project) StopOnly(services ...string) error { ctx := context.Background() err := p.composeProject.Stop(ctx, 10, services...) if err != nil { return err } <-p.stopped return nil }
[ "func", "(", "p", "*", "Project", ")", "StopOnly", "(", "services", "...", "string", ")", "error", "{", "ctx", ":=", "context", ".", "Background", "(", ")", "\n", "err", ":=", "p", ".", "composeProject", ".", "Stop", "(", "ctx", ",", "10", ",", "se...
// StopOnly only stop services without delete them.
[ "StopOnly", "only", "stop", "services", "without", "delete", "them", "." ]
c04e39c026ad1c76c027d6780150c8f7dec0a610
https://github.com/libkermit/compose/blob/c04e39c026ad1c76c027d6780150c8f7dec0a610/compose.go#L112-L120
149,403
libkermit/compose
compose.go
Stop
func (p *Project) Stop(services ...string) error { // FIXME(vdemeester) handle timeout err := p.StopOnly(services...) if err != nil { return err } err = p.composeProject.Delete(context.Background(), options.Delete{}, services...) if err != nil { return err } <-p.deleted existingContainers, err := p.exist...
go
func (p *Project) Stop(services ...string) error { // FIXME(vdemeester) handle timeout err := p.StopOnly(services...) if err != nil { return err } err = p.composeProject.Delete(context.Background(), options.Delete{}, services...) if err != nil { return err } <-p.deleted existingContainers, err := p.exist...
[ "func", "(", "p", "*", "Project", ")", "Stop", "(", "services", "...", "string", ")", "error", "{", "// FIXME(vdemeester) handle timeout", "err", ":=", "p", ".", "StopOnly", "(", "services", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err...
// Stop shuts down and clean the project
[ "Stop", "shuts", "down", "and", "clean", "the", "project" ]
c04e39c026ad1c76c027d6780150c8f7dec0a610
https://github.com/libkermit/compose/blob/c04e39c026ad1c76c027d6780150c8f7dec0a610/compose.go#L123-L149
149,404
libkermit/compose
compose.go
existContainers
func (p *Project) existContainers(stateFiltered project.State, services ...string) (bool, error) { existingContainers := false var err error containersFound, err := p.composeProject.Containers(context.Background(), project.Filter{stateFiltered}) if err == nil && containersFound != nil && len(containersFound) > 0 { ...
go
func (p *Project) existContainers(stateFiltered project.State, services ...string) (bool, error) { existingContainers := false var err error containersFound, err := p.composeProject.Containers(context.Background(), project.Filter{stateFiltered}) if err == nil && containersFound != nil && len(containersFound) > 0 { ...
[ "func", "(", "p", "*", "Project", ")", "existContainers", "(", "stateFiltered", "project", ".", "State", ",", "services", "...", "string", ")", "(", "bool", ",", "error", ")", "{", "existingContainers", ":=", "false", "\n", "var", "err", "error", "\n", "...
// Check if containers exist in the desirated state for the given services
[ "Check", "if", "containers", "exist", "in", "the", "desirated", "state", "for", "the", "given", "services" ]
c04e39c026ad1c76c027d6780150c8f7dec0a610
https://github.com/libkermit/compose/blob/c04e39c026ad1c76c027d6780150c8f7dec0a610/compose.go#L152-L160
149,405
cortesi/termlog
termlog.go
NewLog
func NewLog() *Log { l := &Log{ Palette: &DefaultPalette, enabled: make(map[string]bool), TimeFmt: defaultTimeFmt, } l.enabled[""] = true if !terminal.IsTerminal(int(os.Stdout.Fd())) || os.Getenv("TERM") == "dumb" { l.Color(false) } return l }
go
func NewLog() *Log { l := &Log{ Palette: &DefaultPalette, enabled: make(map[string]bool), TimeFmt: defaultTimeFmt, } l.enabled[""] = true if !terminal.IsTerminal(int(os.Stdout.Fd())) || os.Getenv("TERM") == "dumb" { l.Color(false) } return l }
[ "func", "NewLog", "(", ")", "*", "Log", "{", "l", ":=", "&", "Log", "{", "Palette", ":", "&", "DefaultPalette", ",", "enabled", ":", "make", "(", "map", "[", "string", "]", "bool", ")", ",", "TimeFmt", ":", "defaultTimeFmt", ",", "}", "\n", "l", ...
// NewLog creates a new Log instance and initialises it with a set of defaults.
[ "NewLog", "creates", "a", "new", "Log", "instance", "and", "initialises", "it", "with", "a", "set", "of", "defaults", "." ]
87cefd5ac843f65364f70a1fd2477bb6437690e8
https://github.com/cortesi/termlog/blob/87cefd5ac843f65364f70a1fd2477bb6437690e8/termlog.go#L115-L126
149,406
cortesi/termlog
termlog.go
Group
func (l *Log) Group() Group { return &group{ lines: make([]*line, 0), log: l, quiet: l.quiet, } }
go
func (l *Log) Group() Group { return &group{ lines: make([]*line, 0), log: l, quiet: l.quiet, } }
[ "func", "(", "l", "*", "Log", ")", "Group", "(", ")", "Group", "{", "return", "&", "group", "{", "lines", ":", "make", "(", "[", "]", "*", "line", ",", "0", ")", ",", "log", ":", "l", ",", "quiet", ":", "l", ".", "quiet", ",", "}", "\n", ...
// Group creates a new log group
[ "Group", "creates", "a", "new", "log", "group" ]
87cefd5ac843f65364f70a1fd2477bb6437690e8
https://github.com/cortesi/termlog/blob/87cefd5ac843f65364f70a1fd2477bb6437690e8/termlog.go#L234-L240
149,407
cortesi/termlog
termlog.go
Stream
func (l *Log) Stream(header string) Stream { return &stream{ header: header, log: l, quiet: l.quiet, } }
go
func (l *Log) Stream(header string) Stream { return &stream{ header: header, log: l, quiet: l.quiet, } }
[ "func", "(", "l", "*", "Log", ")", "Stream", "(", "header", "string", ")", "Stream", "{", "return", "&", "stream", "{", "header", ":", "header", ",", "log", ":", "l", ",", "quiet", ":", "l", ".", "quiet", ",", "}", "\n", "}" ]
// Stream creates a new log group
[ "Stream", "creates", "a", "new", "log", "group" ]
87cefd5ac843f65364f70a1fd2477bb6437690e8
https://github.com/cortesi/termlog/blob/87cefd5ac843f65364f70a1fd2477bb6437690e8/termlog.go#L243-L249
149,408
tebeka/strftime
strftime.go
repl
func repl(match string, t time.Time) string { if match == "%%" { return "%" } format, ok := conv[match] if ok { return t.Format(format) } switch match { case "%j": start := time.Date(t.Year(), time.January, 1, 0, 0, 0, 0, time.UTC) day := int(t.Sub(start).Hours()/24) + 1 return fmt.Sprintf("%03d", da...
go
func repl(match string, t time.Time) string { if match == "%%" { return "%" } format, ok := conv[match] if ok { return t.Format(format) } switch match { case "%j": start := time.Date(t.Year(), time.January, 1, 0, 0, 0, 0, time.UTC) day := int(t.Sub(start).Hours()/24) + 1 return fmt.Sprintf("%03d", da...
[ "func", "repl", "(", "match", "string", ",", "t", "time", ".", "Time", ")", "string", "{", "if", "match", "==", "\"", "\"", "{", "return", "\"", "\"", "\n", "}", "\n\n", "format", ",", "ok", ":=", "conv", "[", "match", "]", "\n", "if", "ok", "{...
// repl replaces % directives with right time, will panic on unknown directive
[ "repl", "replaces", "%", "directives", "with", "right", "time", "will", "panic", "on", "unknown", "directive" ]
3f9c7761e3124a331848c11a2f168afd8b105d9f
https://github.com/tebeka/strftime/blob/3f9c7761e3124a331848c11a2f168afd8b105d9f/strftime.go#L74-L104
149,409
tebeka/strftime
strftime.go
Format
func Format(format string, t time.Time) (result string, err error) { defer func() { if e := recover(); e != nil { result = "" err = e.(error) } }() fn := func(match string) string { return repl(match, t) } return fmtRe.ReplaceAllStringFunc(format, fn), nil }
go
func Format(format string, t time.Time) (result string, err error) { defer func() { if e := recover(); e != nil { result = "" err = e.(error) } }() fn := func(match string) string { return repl(match, t) } return fmtRe.ReplaceAllStringFunc(format, fn), nil }
[ "func", "Format", "(", "format", "string", ",", "t", "time", ".", "Time", ")", "(", "result", "string", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "if", "e", ":=", "recover", "(", ")", ";", "e", "!=", "nil", "{", "result", "...
// Format return string with % directives expanded. // Will return error on unknown directive.
[ "Format", "return", "string", "with", "%", "directives", "expanded", ".", "Will", "return", "error", "on", "unknown", "directive", "." ]
3f9c7761e3124a331848c11a2f168afd8b105d9f
https://github.com/tebeka/strftime/blob/3f9c7761e3124a331848c11a2f168afd8b105d9f/strftime.go#L108-L120
149,410
libkermit/compose
check/compose.go
Container
func (p *Project) Container(c *check.C, service string) types.ContainerJSON { container, err := p.project.Container(service) c.Assert(err, check.IsNil, check.Commentf("error while getting the container for service '%s'", service)) return container }
go
func (p *Project) Container(c *check.C, service string) types.ContainerJSON { container, err := p.project.Container(service) c.Assert(err, check.IsNil, check.Commentf("error while getting the container for service '%s'", service)) return container }
[ "func", "(", "p", "*", "Project", ")", "Container", "(", "c", "*", "check", ".", "C", ",", "service", "string", ")", "types", ".", "ContainerJSON", "{", "container", ",", "err", ":=", "p", ".", "project", ".", "Container", "(", "service", ")", "\n", ...
// Container return the one and only container for a given services. // It fails if there is more than one container for the service.
[ "Container", "return", "the", "one", "and", "only", "container", "for", "a", "given", "services", ".", "It", "fails", "if", "there", "is", "more", "than", "one", "container", "for", "the", "service", "." ]
c04e39c026ad1c76c027d6780150c8f7dec0a610
https://github.com/libkermit/compose/blob/c04e39c026ad1c76c027d6780150c8f7dec0a610/check/compose.go#L86-L91
149,411
libkermit/compose
check/compose.go
NoContainer
func (p *Project) NoContainer(c *check.C, service string) { validErr := "No container found for '" + service + "' service" _, err := p.project.Container(service) c.Assert(err, check.NotNil, check.Commentf("error while getting the container for service '%s'", service)) c.Assert(err.Error(), check.Equals, validErr,...
go
func (p *Project) NoContainer(c *check.C, service string) { validErr := "No container found for '" + service + "' service" _, err := p.project.Container(service) c.Assert(err, check.NotNil, check.Commentf("error while getting the container for service '%s'", service)) c.Assert(err.Error(), check.Equals, validErr,...
[ "func", "(", "p", "*", "Project", ")", "NoContainer", "(", "c", "*", "check", ".", "C", ",", "service", "string", ")", "{", "validErr", ":=", "\"", "\"", "+", "service", "+", "\"", "\"", "\n", "_", ",", "err", ":=", "p", ".", "project", ".", "C...
// NoContainer check is there is no container for the service given // It fails if there one or more containers or if the error returned // does not indicate an empty container list
[ "NoContainer", "check", "is", "there", "is", "no", "container", "for", "the", "service", "given", "It", "fails", "if", "there", "one", "or", "more", "containers", "or", "if", "the", "error", "returned", "does", "not", "indicate", "an", "empty", "container", ...
c04e39c026ad1c76c027d6780150c8f7dec0a610
https://github.com/libkermit/compose/blob/c04e39c026ad1c76c027d6780150c8f7dec0a610/check/compose.go#L96-L103
149,412
cortesi/termlog
group.go
Done
func (g *group) Done() { g.log.output(g.quiet, g.lines...) }
go
func (g *group) Done() { g.log.output(g.quiet, g.lines...) }
[ "func", "(", "g", "*", "group", ")", "Done", "(", ")", "{", "g", ".", "log", ".", "output", "(", "g", ".", "quiet", ",", "g", ".", "lines", "...", ")", "\n", "}" ]
// Done outputs the group to screen
[ "Done", "outputs", "the", "group", "to", "screen" ]
87cefd5ac843f65364f70a1fd2477bb6437690e8
https://github.com/cortesi/termlog/blob/87cefd5ac843f65364f70a1fd2477bb6437690e8/group.go#L65-L67
149,413
cortesi/termlog
stream.go
Header
func (s *stream) Header() { outputMutex.Lock() defer outputMutex.Unlock() s.log.header(s) }
go
func (s *stream) Header() { outputMutex.Lock() defer outputMutex.Unlock() s.log.header(s) }
[ "func", "(", "s", "*", "stream", ")", "Header", "(", ")", "{", "outputMutex", ".", "Lock", "(", ")", "\n", "defer", "outputMutex", ".", "Unlock", "(", ")", "\n", "s", ".", "log", ".", "header", "(", "s", ")", "\n", "}" ]
// Header immedately outputs the stream header
[ "Header", "immedately", "outputs", "the", "stream", "header" ]
87cefd5ac843f65364f70a1fd2477bb6437690e8
https://github.com/cortesi/termlog/blob/87cefd5ac843f65364f70a1fd2477bb6437690e8/stream.go#L72-L76
149,414
octavore/nagax
config/debug.go
PrintConsolidatedConfig
func (m *Module) PrintConsolidatedConfig() { for _, typ := range m.configDefs { if typ.Kind() == reflect.Ptr && typ.Elem().Kind() == reflect.Struct { typ = typ.Elem() } m.printFieldsWithTags(typ, 0) } }
go
func (m *Module) PrintConsolidatedConfig() { for _, typ := range m.configDefs { if typ.Kind() == reflect.Ptr && typ.Elem().Kind() == reflect.Struct { typ = typ.Elem() } m.printFieldsWithTags(typ, 0) } }
[ "func", "(", "m", "*", "Module", ")", "PrintConsolidatedConfig", "(", ")", "{", "for", "_", ",", "typ", ":=", "range", "m", ".", "configDefs", "{", "if", "typ", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "&&", "typ", ".", "Elem", "(", ")...
// PrintConsolidatedConfig prints out the definitions of all config
[ "PrintConsolidatedConfig", "prints", "out", "the", "definitions", "of", "all", "config" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/config/debug.go#L10-L17
149,415
bartmeuris/progressio
byteformatter.go
FormatSize
func FormatSize(ss SizeSystem, size int64, short bool) string { div, name, shortnm := getUnit(ss, size) ds := float64(size) / float64(div) numfm := "%.2f" if div == 1 { numfm = "%.0f" } if short { return fmt.Sprintf(numfm+"%s", ds, shortnm) } return fmt.Sprintf(numfm+" %s", ds, name) }
go
func FormatSize(ss SizeSystem, size int64, short bool) string { div, name, shortnm := getUnit(ss, size) ds := float64(size) / float64(div) numfm := "%.2f" if div == 1 { numfm = "%.0f" } if short { return fmt.Sprintf(numfm+"%s", ds, shortnm) } return fmt.Sprintf(numfm+" %s", ds, name) }
[ "func", "FormatSize", "(", "ss", "SizeSystem", ",", "size", "int64", ",", "short", "bool", ")", "string", "{", "div", ",", "name", ",", "shortnm", ":=", "getUnit", "(", "ss", ",", "size", ")", "\n", "ds", ":=", "float64", "(", "size", ")", "/", "fl...
// FormatSize formats a number of bytes using the given unit standard system. // If the 'short' flag is set to true, it uses the shortened names.
[ "FormatSize", "formats", "a", "number", "of", "bytes", "using", "the", "given", "unit", "standard", "system", ".", "If", "the", "short", "flag", "is", "set", "to", "true", "it", "uses", "the", "shortened", "names", "." ]
387f5796a6e8b84e8f9b3c1c0a97769b6b83adac
https://github.com/bartmeuris/progressio/blob/387f5796a6e8b84e8f9b3c1c0a97769b6b83adac/byteformatter.go#L137-L148
149,416
octavore/nagax
users/session/module.go
loadKeys
func loadKeys(keyFile string, keyStore KeyStore) (jose.Encrypter, interface{}, error) { privateKey, _, err := keyStore.LoadPrivateKey(keyFile) if err != nil { return nil, nil, err } decryptionKey, err := jose.LoadPrivateKey(privateKey) if err != nil { return nil, nil, err } pub, err := keyStore.LoadPublicKe...
go
func loadKeys(keyFile string, keyStore KeyStore) (jose.Encrypter, interface{}, error) { privateKey, _, err := keyStore.LoadPrivateKey(keyFile) if err != nil { return nil, nil, err } decryptionKey, err := jose.LoadPrivateKey(privateKey) if err != nil { return nil, nil, err } pub, err := keyStore.LoadPublicKe...
[ "func", "loadKeys", "(", "keyFile", "string", ",", "keyStore", "KeyStore", ")", "(", "jose", ".", "Encrypter", ",", "interface", "{", "}", ",", "error", ")", "{", "privateKey", ",", "_", ",", "err", ":=", "keyStore", ".", "LoadPrivateKey", "(", "keyFile"...
// load keys from the keystore
[ "load", "keys", "from", "the", "keystore" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/session/module.go#L96-L121
149,417
octavore/nagax
users/module.go
RegisterAuthenticator
func (m *Module) RegisterAuthenticator(a Authenticator) { m.Authenticators = append(m.Authenticators, a) }
go
func (m *Module) RegisterAuthenticator(a Authenticator) { m.Authenticators = append(m.Authenticators, a) }
[ "func", "(", "m", "*", "Module", ")", "RegisterAuthenticator", "(", "a", "Authenticator", ")", "{", "m", ".", "Authenticators", "=", "append", "(", "m", ".", "Authenticators", ",", "a", ")", "\n", "}" ]
// RegisterAuthenticator registers a new authenticator
[ "RegisterAuthenticator", "registers", "a", "new", "authenticator" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/module.go#L20-L22
149,418
octavore/nagax
users/module.go
Init
func (m *Module) Init(c *service.Config) { c.Setup = func() error { m.BaseAuthenticator = m return nil } }
go
func (m *Module) Init(c *service.Config) { c.Setup = func() error { m.BaseAuthenticator = m return nil } }
[ "func", "(", "m", "*", "Module", ")", "Init", "(", "c", "*", "service", ".", "Config", ")", "{", "c", ".", "Setup", "=", "func", "(", ")", "error", "{", "m", ".", "BaseAuthenticator", "=", "m", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Init implements the Module interface method
[ "Init", "implements", "the", "Module", "interface", "method" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/module.go#L25-L30
149,419
octavore/nagax
static/module.go
Init
func (m *Module) Init(c *service.Config) { c.Setup = func() error { m.Router.HTTPRouter.NotFound = m m.staticBasePath = defaultStaticBasePath m.staticDirs = defaultStaticDirs m.handle404 = m.DefaultHandle404 m.handle500 = m.DefaultHandle500 return nil } c.Start = func() { m.Router.Root.Handle(m.staticB...
go
func (m *Module) Init(c *service.Config) { c.Setup = func() error { m.Router.HTTPRouter.NotFound = m m.staticBasePath = defaultStaticBasePath m.staticDirs = defaultStaticDirs m.handle404 = m.DefaultHandle404 m.handle500 = m.DefaultHandle500 return nil } c.Start = func() { m.Router.Root.Handle(m.staticB...
[ "func", "(", "m", "*", "Module", ")", "Init", "(", "c", "*", "service", ".", "Config", ")", "{", "c", ".", "Setup", "=", "func", "(", ")", "error", "{", "m", ".", "Router", ".", "HTTPRouter", ".", "NotFound", "=", "m", "\n", "m", ".", "staticBa...
// Init this module
[ "Init", "this", "module" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/static/module.go#L41-L53
149,420
octavore/nagax
static/module.go
Configure
func (m *Module) Configure(opts ...option) { for _, opt := range opts { opt(m) } }
go
func (m *Module) Configure(opts ...option) { for _, opt := range opts { opt(m) } }
[ "func", "(", "m", "*", "Module", ")", "Configure", "(", "opts", "...", "option", ")", "{", "for", "_", ",", "opt", ":=", "range", "opts", "{", "opt", "(", "m", ")", "\n", "}", "\n", "}" ]
// Configure this module with given options
[ "Configure", "this", "module", "with", "given", "options" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/static/module.go#L56-L60
149,421
octavore/nagax
static/module.go
DefaultHandle404
func (m *Module) DefaultHandle404(rw http.ResponseWriter, req *http.Request) { rw.WriteHeader(http.StatusNotFound) }
go
func (m *Module) DefaultHandle404(rw http.ResponseWriter, req *http.Request) { rw.WriteHeader(http.StatusNotFound) }
[ "func", "(", "m", "*", "Module", ")", "DefaultHandle404", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "rw", ".", "WriteHeader", "(", "http", ".", "StatusNotFound", ")", "\n", "}" ]
// DefaultHandle404 default 404 handler
[ "DefaultHandle404", "default", "404", "handler" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/static/module.go#L63-L65
149,422
octavore/nagax
static/module.go
DefaultHandle500
func (m *Module) DefaultHandle500(rw http.ResponseWriter, req *http.Request, err error) { m.Logger.Errorf("%s: %s", req.URL, err) http.Error(rw, "internal server error", http.StatusInternalServerError) }
go
func (m *Module) DefaultHandle500(rw http.ResponseWriter, req *http.Request, err error) { m.Logger.Errorf("%s: %s", req.URL, err) http.Error(rw, "internal server error", http.StatusInternalServerError) }
[ "func", "(", "m", "*", "Module", ")", "DefaultHandle500", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "err", "error", ")", "{", "m", ".", "Logger", ".", "Errorf", "(", "\"", "\"", ",", "req", ".", "URL", ...
// DefaultHandle500 default 500 handler
[ "DefaultHandle500", "default", "500", "handler" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/static/module.go#L68-L71
149,423
octavore/nagax
static/module.go
ServeAsset
func (m *Module) ServeAsset(rw http.ResponseWriter, req *http.Request, filepath string, customErrHandler bool) { ext := path.Ext(filepath) b, err := m.box.MustBytes(filepath) if err != nil { if !customErrHandler { m.Logger.Errorf("%s: %s", req.URL, err) rw.WriteHeader(http.StatusNotFound) return } sw...
go
func (m *Module) ServeAsset(rw http.ResponseWriter, req *http.Request, filepath string, customErrHandler bool) { ext := path.Ext(filepath) b, err := m.box.MustBytes(filepath) if err != nil { if !customErrHandler { m.Logger.Errorf("%s: %s", req.URL, err) rw.WriteHeader(http.StatusNotFound) return } sw...
[ "func", "(", "m", "*", "Module", ")", "ServeAsset", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "filepath", "string", ",", "customErrHandler", "bool", ")", "{", "ext", ":=", "path", ".", "Ext", "(", "filepath...
// ServeAsset serves a filepath from the packr box. handle404 and handle500 // should not recurse.
[ "ServeAsset", "serves", "a", "filepath", "from", "the", "packr", "box", ".", "handle404", "and", "handle500", "should", "not", "recurse", "." ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/static/module.go#L93-L114
149,424
octavore/nagax
users/session/create.go
CreateSession
func (m *Module) CreateSession(userToken string, rw http.ResponseWriter) error { cookie, err := m.newSessionCookie(&UserSession{ ID: userToken, SessionID: fmt.Sprintf("%s-%d", userToken, time.Now().UnixNano()), }) if err != nil { return err } http.SetCookie(rw, cookie) return nil }
go
func (m *Module) CreateSession(userToken string, rw http.ResponseWriter) error { cookie, err := m.newSessionCookie(&UserSession{ ID: userToken, SessionID: fmt.Sprintf("%s-%d", userToken, time.Now().UnixNano()), }) if err != nil { return err } http.SetCookie(rw, cookie) return nil }
[ "func", "(", "m", "*", "Module", ")", "CreateSession", "(", "userToken", "string", ",", "rw", "http", ".", "ResponseWriter", ")", "error", "{", "cookie", ",", "err", ":=", "m", ".", "newSessionCookie", "(", "&", "UserSession", "{", "ID", ":", "userToken"...
// CreateSession update the response with a session cookie
[ "CreateSession", "update", "the", "response", "with", "a", "session", "cookie" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/session/create.go#L10-L20
149,425
octavore/nagax
bugsnag/module.go
Notify
func (m *Module) Notify(err error, rawData ...interface{}) { rawData = append(rawData, bugsnagGo.SeverityError) if re, ok := err.(GetRequestable); ok && re.GetRequest() != nil { rawData = append(rawData, re.GetRequest()) } errType := "error" if err2, ok := err.(*goerrors.Error); ok { errType = fmt.Sprintf("%T"...
go
func (m *Module) Notify(err error, rawData ...interface{}) { rawData = append(rawData, bugsnagGo.SeverityError) if re, ok := err.(GetRequestable); ok && re.GetRequest() != nil { rawData = append(rawData, re.GetRequest()) } errType := "error" if err2, ok := err.(*goerrors.Error); ok { errType = fmt.Sprintf("%T"...
[ "func", "(", "m", "*", "Module", ")", "Notify", "(", "err", "error", ",", "rawData", "...", "interface", "{", "}", ")", "{", "rawData", "=", "append", "(", "rawData", ",", "bugsnagGo", ".", "SeverityError", ")", "\n", "if", "re", ",", "ok", ":=", "...
// Notify bugsnag, note that m.Logger.Error calls Notify so Notify musn't call m.Logger.Error
[ "Notify", "bugsnag", "note", "that", "m", ".", "Logger", ".", "Error", "calls", "Notify", "so", "Notify", "musn", "t", "call", "m", ".", "Logger", ".", "Error" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/bugsnag/module.go#L80-L104
149,426
octavore/nagax
config/module.go
Init
func (m *Module) Init(c *service.Config) { c.Setup = func() error { m.configDefs = []reflect.Type{} switch { case m.ConfigPath != "": // do nothing case os.Getenv(ConfigEnv) != "": m.ConfigPath = os.Getenv(ConfigEnv) default: m.ConfigPath = "config.json" } err := m.LoadConfig(m.ConfigPath) // ...
go
func (m *Module) Init(c *service.Config) { c.Setup = func() error { m.configDefs = []reflect.Type{} switch { case m.ConfigPath != "": // do nothing case os.Getenv(ConfigEnv) != "": m.ConfigPath = os.Getenv(ConfigEnv) default: m.ConfigPath = "config.json" } err := m.LoadConfig(m.ConfigPath) // ...
[ "func", "(", "m", "*", "Module", ")", "Init", "(", "c", "*", "service", ".", "Config", ")", "{", "c", ".", "Setup", "=", "func", "(", ")", "error", "{", "m", ".", "configDefs", "=", "[", "]", "reflect", ".", "Type", "{", "}", "\n", "switch", ...
// Init implements the module interface method
[ "Init", "implements", "the", "module", "interface", "method" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/config/module.go#L31-L65
149,427
octavore/nagax
config/module.go
LoadConfig
func (m *Module) LoadConfig(path string) error { _, err := os.Stat(path) if err != nil { if os.IsNotExist(err) { m.Byte = []byte(`{}`) return nil } return err } m.Byte, err = ioutil.ReadFile(path) if err != nil { return err } return nil }
go
func (m *Module) LoadConfig(path string) error { _, err := os.Stat(path) if err != nil { if os.IsNotExist(err) { m.Byte = []byte(`{}`) return nil } return err } m.Byte, err = ioutil.ReadFile(path) if err != nil { return err } return nil }
[ "func", "(", "m", "*", "Module", ")", "LoadConfig", "(", "path", "string", ")", "error", "{", "_", ",", "err", ":=", "os", ".", "Stat", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "if", "os", ".", "IsNotExist", "(", "err", ")", "{", ...
// LoadConfig loads the config json file from the given path
[ "LoadConfig", "loads", "the", "config", "json", "file", "from", "the", "given", "path" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/config/module.go#L68-L82
149,428
octavore/nagax
config/module.go
ReadConfig
func (m *Module) ReadConfig(i interface{}) error { m.configDefs = append(m.configDefs, reflect.TypeOf(i)) return json.Unmarshal(m.Byte, i) }
go
func (m *Module) ReadConfig(i interface{}) error { m.configDefs = append(m.configDefs, reflect.TypeOf(i)) return json.Unmarshal(m.Byte, i) }
[ "func", "(", "m", "*", "Module", ")", "ReadConfig", "(", "i", "interface", "{", "}", ")", "error", "{", "m", ".", "configDefs", "=", "append", "(", "m", ".", "configDefs", ",", "reflect", ".", "TypeOf", "(", "i", ")", ")", "\n", "return", "json", ...
// ReadConfig json-decodes the config file bytes into i, which should be a pointer // to a struct.
[ "ReadConfig", "json", "-", "decodes", "the", "config", "file", "bytes", "into", "i", "which", "should", "be", "a", "pointer", "to", "a", "struct", "." ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/config/module.go#L86-L89
149,429
octavore/nagax
config/module.go
Getenv
func (m *Module) Getenv(key string) string { if _, ok := m.Env[key]; !ok { m.Env[key] = os.Getenv(key) } return m.Env[key] }
go
func (m *Module) Getenv(key string) string { if _, ok := m.Env[key]; !ok { m.Env[key] = os.Getenv(key) } return m.Env[key] }
[ "func", "(", "m", "*", "Module", ")", "Getenv", "(", "key", "string", ")", "string", "{", "if", "_", ",", "ok", ":=", "m", ".", "Env", "[", "key", "]", ";", "!", "ok", "{", "m", ".", "Env", "[", "key", "]", "=", "os", ".", "Getenv", "(", ...
// Getenv reads and caches env variable
[ "Getenv", "reads", "and", "caches", "env", "variable" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/config/module.go#L92-L97
149,430
octavore/nagax
users/csrf/csrf.go
New
func (m *Module) New(state string) (string, error) { b, err := json.Marshal(&csrfPayload{ State: state, Token: token.New32(), ExpireAfter: time.Now().Add(m.csrfValidityDuration), }) if err != nil { return "", err } obj, err := m.encrypter.Encrypt(b) if err != nil { return "", err } msg, ...
go
func (m *Module) New(state string) (string, error) { b, err := json.Marshal(&csrfPayload{ State: state, Token: token.New32(), ExpireAfter: time.Now().Add(m.csrfValidityDuration), }) if err != nil { return "", err } obj, err := m.encrypter.Encrypt(b) if err != nil { return "", err } msg, ...
[ "func", "(", "m", "*", "Module", ")", "New", "(", "state", "string", ")", "(", "string", ",", "error", ")", "{", "b", ",", "err", ":=", "json", ".", "Marshal", "(", "&", "csrfPayload", "{", "State", ":", "state", ",", "Token", ":", "token", ".", ...
// New creates a new encrypted token for the given UserSession
[ "New", "creates", "a", "new", "encrypted", "token", "for", "the", "given", "UserSession" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/csrf/csrf.go#L21-L42
149,431
octavore/nagax
users/csrf/csrf.go
Decode
func (m *Module) Decode(token string) (*csrfPayload, error) { obj, err := jose.ParseEncrypted(token) if err != nil { return nil, err } b, err := obj.Decrypt(m.decryptionKey) csrfPayload := &csrfPayload{} if err = json.Unmarshal(b, csrfPayload); err != nil { return nil, err } if time.Now().After(csrfPayload....
go
func (m *Module) Decode(token string) (*csrfPayload, error) { obj, err := jose.ParseEncrypted(token) if err != nil { return nil, err } b, err := obj.Decrypt(m.decryptionKey) csrfPayload := &csrfPayload{} if err = json.Unmarshal(b, csrfPayload); err != nil { return nil, err } if time.Now().After(csrfPayload....
[ "func", "(", "m", "*", "Module", ")", "Decode", "(", "token", "string", ")", "(", "*", "csrfPayload", ",", "error", ")", "{", "obj", ",", "err", ":=", "jose", ".", "ParseEncrypted", "(", "token", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// Decode an encrypted token
[ "Decode", "an", "encrypted", "token" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/csrf/csrf.go#L45-L59
149,432
octavore/nagax
users/csrf/csrf.go
Verify
func (m *Module) Verify(state, token string) (bool, error) { obj, err := jose.ParseEncrypted(token) if err != nil { return false, errors.Wrap(err) } b, err := obj.Decrypt(m.decryptionKey) csrfPayload := &csrfPayload{} if err = json.Unmarshal(b, csrfPayload); err != nil { return false, errors.Wrap(err) } if ...
go
func (m *Module) Verify(state, token string) (bool, error) { obj, err := jose.ParseEncrypted(token) if err != nil { return false, errors.Wrap(err) } b, err := obj.Decrypt(m.decryptionKey) csrfPayload := &csrfPayload{} if err = json.Unmarshal(b, csrfPayload); err != nil { return false, errors.Wrap(err) } if ...
[ "func", "(", "m", "*", "Module", ")", "Verify", "(", "state", ",", "token", "string", ")", "(", "bool", ",", "error", ")", "{", "obj", ",", "err", ":=", "jose", ".", "ParseEncrypted", "(", "token", ")", "\n", "if", "err", "!=", "nil", "{", "retur...
// Verify an encrypted token
[ "Verify", "an", "encrypted", "token" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/csrf/csrf.go#L62-L79
149,433
octavore/nagax
users/session/revocation.go
NewInMemoryRevocationStore
func NewInMemoryRevocationStore(flushInterval time.Duration) *InMemoryRevocationStore { return &InMemoryRevocationStore{ revoked: map[string]time.Time{}, flushInterval: flushInterval, } }
go
func NewInMemoryRevocationStore(flushInterval time.Duration) *InMemoryRevocationStore { return &InMemoryRevocationStore{ revoked: map[string]time.Time{}, flushInterval: flushInterval, } }
[ "func", "NewInMemoryRevocationStore", "(", "flushInterval", "time", ".", "Duration", ")", "*", "InMemoryRevocationStore", "{", "return", "&", "InMemoryRevocationStore", "{", "revoked", ":", "map", "[", "string", "]", "time", ".", "Time", "{", "}", ",", "flushInt...
// NewInMemoryRevocationStore returns a new in memory revocation store // which checks for expired tokens every flushInterval
[ "NewInMemoryRevocationStore", "returns", "a", "new", "in", "memory", "revocation", "store", "which", "checks", "for", "expired", "tokens", "every", "flushInterval" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/session/revocation.go#L15-L20
149,434
octavore/nagax
users/session/revocation.go
Start
func (s *InMemoryRevocationStore) Start() { if s.ticker != nil { return } now := time.Now() s.ticker = time.NewTicker(s.flushInterval) for range s.ticker.C { for session, expiry := range s.revoked { if now.After(expiry) { delete(s.revoked, session) } } } }
go
func (s *InMemoryRevocationStore) Start() { if s.ticker != nil { return } now := time.Now() s.ticker = time.NewTicker(s.flushInterval) for range s.ticker.C { for session, expiry := range s.revoked { if now.After(expiry) { delete(s.revoked, session) } } } }
[ "func", "(", "s", "*", "InMemoryRevocationStore", ")", "Start", "(", ")", "{", "if", "s", ".", "ticker", "!=", "nil", "{", "return", "\n", "}", "\n", "now", ":=", "time", ".", "Now", "(", ")", "\n", "s", ".", "ticker", "=", "time", ".", "NewTicke...
// Start the collection job
[ "Start", "the", "collection", "job" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/session/revocation.go#L23-L36
149,435
octavore/nagax
users/session/revocation.go
Revoke
func (s *InMemoryRevocationStore) Revoke(id string, trackFor time.Duration) { s.revoked[id] = time.Now().Add(trackFor) }
go
func (s *InMemoryRevocationStore) Revoke(id string, trackFor time.Duration) { s.revoked[id] = time.Now().Add(trackFor) }
[ "func", "(", "s", "*", "InMemoryRevocationStore", ")", "Revoke", "(", "id", "string", ",", "trackFor", "time", ".", "Duration", ")", "{", "s", ".", "revoked", "[", "id", "]", "=", "time", ".", "Now", "(", ")", ".", "Add", "(", "trackFor", ")", "\n"...
// Revoke implements the interface method
[ "Revoke", "implements", "the", "interface", "method" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/session/revocation.go#L45-L47
149,436
octavore/nagax
users/session/revocation.go
IsRevoked
func (s *InMemoryRevocationStore) IsRevoked(id string) bool { _, inStore := s.revoked[id] // if in store, assume revoked return inStore }
go
func (s *InMemoryRevocationStore) IsRevoked(id string) bool { _, inStore := s.revoked[id] // if in store, assume revoked return inStore }
[ "func", "(", "s", "*", "InMemoryRevocationStore", ")", "IsRevoked", "(", "id", "string", ")", "bool", "{", "_", ",", "inStore", ":=", "s", ".", "revoked", "[", "id", "]", "\n", "// if in store, assume revoked", "return", "inStore", "\n", "}" ]
// IsRevoked implements the interface method
[ "IsRevoked", "implements", "the", "interface", "method" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/session/revocation.go#L50-L54
149,437
octavore/nagax
users/session/user_session.go
newSessionCookie
func (m *Module) newSessionCookie(u *UserSession) (*http.Cookie, error) { return m.newScopedSessionCookie(u, m.CookieDomain) }
go
func (m *Module) newSessionCookie(u *UserSession) (*http.Cookie, error) { return m.newScopedSessionCookie(u, m.CookieDomain) }
[ "func", "(", "m", "*", "Module", ")", "newSessionCookie", "(", "u", "*", "UserSession", ")", "(", "*", "http", ".", "Cookie", ",", "error", ")", "{", "return", "m", ".", "newScopedSessionCookie", "(", "u", ",", "m", ".", "CookieDomain", ")", "\n", "}...
// newSessionCookie creates a new encrypted cookie for the given UserSession
[ "newSessionCookie", "creates", "a", "new", "encrypted", "cookie", "for", "the", "given", "UserSession" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/session/user_session.go#L51-L53
149,438
octavore/nagax
users/session/user_session.go
getSessionFromRequest
func (m *Module) getSessionFromRequest(req *http.Request) (*UserSession, error) { cookie, err := req.Cookie(m.CookieName) if err == http.ErrNoCookie { return nil, nil } else if err != nil { m.Logger.Error(errors.Wrap(err)) return nil, nil } obj, err := jose.ParseEncrypted(cookie.Value) if err != nil { m....
go
func (m *Module) getSessionFromRequest(req *http.Request) (*UserSession, error) { cookie, err := req.Cookie(m.CookieName) if err == http.ErrNoCookie { return nil, nil } else if err != nil { m.Logger.Error(errors.Wrap(err)) return nil, nil } obj, err := jose.ParseEncrypted(cookie.Value) if err != nil { m....
[ "func", "(", "m", "*", "Module", ")", "getSessionFromRequest", "(", "req", "*", "http", ".", "Request", ")", "(", "*", "UserSession", ",", "error", ")", "{", "cookie", ",", "err", ":=", "req", ".", "Cookie", "(", "m", ".", "CookieName", ")", "\n", ...
// getSessionFromRequest reads the current session from the request, // and if it is valid, returns the corresponding UserSession. // No error if there was no cookie, or the cookie was valid. // If there is an invalid cookie, an error is returned.
[ "getSessionFromRequest", "reads", "the", "current", "session", "from", "the", "request", "and", "if", "it", "is", "valid", "returns", "the", "corresponding", "UserSession", ".", "No", "error", "if", "there", "was", "no", "cookie", "or", "the", "cookie", "was",...
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/session/user_session.go#L59-L85
149,439
octavore/nagax
router/response.go
ProtoOK
func ProtoOK(rw http.ResponseWriter, pb proto.Message) error { return Proto(rw, http.StatusOK, pb) }
go
func ProtoOK(rw http.ResponseWriter, pb proto.Message) error { return Proto(rw, http.StatusOK, pb) }
[ "func", "ProtoOK", "(", "rw", "http", ".", "ResponseWriter", ",", "pb", "proto", ".", "Message", ")", "error", "{", "return", "Proto", "(", "rw", ",", "http", ".", "StatusOK", ",", "pb", ")", "\n", "}" ]
// ProtoOK renders a 200 response with JSON-serialized proto
[ "ProtoOK", "renders", "a", "200", "response", "with", "JSON", "-", "serialized", "proto" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/router/response.go#L17-L19
149,440
octavore/nagax
router/response.go
Proto
func Proto(rw http.ResponseWriter, status int, pb proto.Message) error { rw.Header().Set("Content-Type", "application/json") rw.WriteHeader(status) return jpb.Marshal(rw, pb) }
go
func Proto(rw http.ResponseWriter, status int, pb proto.Message) error { rw.Header().Set("Content-Type", "application/json") rw.WriteHeader(status) return jpb.Marshal(rw, pb) }
[ "func", "Proto", "(", "rw", "http", ".", "ResponseWriter", ",", "status", "int", ",", "pb", "proto", ".", "Message", ")", "error", "{", "rw", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "rw", ".", "WriteHeade...
// Proto renders a response with given status code and JSON-serialized proto
[ "Proto", "renders", "a", "response", "with", "given", "status", "code", "and", "JSON", "-", "serialized", "proto" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/router/response.go#L22-L26
149,441
octavore/nagax
router/response.go
JSON
func JSON(rw http.ResponseWriter, status int, v interface{}) error { if pb, ok := v.(proto.Message); ok { return Proto(rw, status, pb) } b, err := json.MarshalIndent(v, "", " ") if err != nil { return err } rw.Header().Add("Content-Type", "application/json") rw.WriteHeader(status) _, err = rw.Write(b) re...
go
func JSON(rw http.ResponseWriter, status int, v interface{}) error { if pb, ok := v.(proto.Message); ok { return Proto(rw, status, pb) } b, err := json.MarshalIndent(v, "", " ") if err != nil { return err } rw.Header().Add("Content-Type", "application/json") rw.WriteHeader(status) _, err = rw.Write(b) re...
[ "func", "JSON", "(", "rw", "http", ".", "ResponseWriter", ",", "status", "int", ",", "v", "interface", "{", "}", ")", "error", "{", "if", "pb", ",", "ok", ":=", "v", ".", "(", "proto", ".", "Message", ")", ";", "ok", "{", "return", "Proto", "(", ...
// JSON renders a response with given status and JSON serialized data
[ "JSON", "renders", "a", "response", "with", "given", "status", "and", "JSON", "serialized", "data" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/router/response.go#L29-L42
149,442
octavore/nagax
users/csrf/options.go
WithValidity
func WithValidity(t time.Duration) option { return func(m *Module) { m.csrfValidityDuration = t } }
go
func WithValidity(t time.Duration) option { return func(m *Module) { m.csrfValidityDuration = t } }
[ "func", "WithValidity", "(", "t", "time", ".", "Duration", ")", "option", "{", "return", "func", "(", "m", "*", "Module", ")", "{", "m", ".", "csrfValidityDuration", "=", "t", "\n", "}", "\n", "}" ]
// WithValidity configures how long the csrf tokens are valid for.
[ "WithValidity", "configures", "how", "long", "the", "csrf", "tokens", "are", "valid", "for", "." ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/csrf/options.go#L8-L12
149,443
octavore/nagax
router/module.go
Init
func (m *Module) Init(c *service.Config) { c.Setup = func() error { m.HTTPRouter = httprouter.New() m.ErrorHandler = func(rw http.ResponseWriter, req *http.Request, err error) { _ = m.HandleError(rw, req, err) } m.ErrorPage = func(rw http.ResponseWriter, req *http.Request, status int) { http.Error(rw, fm...
go
func (m *Module) Init(c *service.Config) { c.Setup = func() error { m.HTTPRouter = httprouter.New() m.ErrorHandler = func(rw http.ResponseWriter, req *http.Request, err error) { _ = m.HandleError(rw, req, err) } m.ErrorPage = func(rw http.ResponseWriter, req *http.Request, status int) { http.Error(rw, fm...
[ "func", "(", "m", "*", "Module", ")", "Init", "(", "c", "*", "service", ".", "Config", ")", "{", "c", ".", "Setup", "=", "func", "(", ")", "error", "{", "m", ".", "HTTPRouter", "=", "httprouter", ".", "New", "(", ")", "\n", "m", ".", "ErrorHand...
// Init implements service.Init
[ "Init", "implements", "service", ".", "Init" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/router/module.go#L46-L74
149,444
octavore/nagax
router/module.go
Shutdown
func (m *Module) Shutdown(ctx context.Context) { m.Logger.Infof("shutting down %s...", m.server.Addr) err := m.server.Shutdown(ctx) if err != nil { m.Logger.Error(errors.Wrap(err)) } }
go
func (m *Module) Shutdown(ctx context.Context) { m.Logger.Infof("shutting down %s...", m.server.Addr) err := m.server.Shutdown(ctx) if err != nil { m.Logger.Error(errors.Wrap(err)) } }
[ "func", "(", "m", "*", "Module", ")", "Shutdown", "(", "ctx", "context", ".", "Context", ")", "{", "m", ".", "Logger", ".", "Infof", "(", "\"", "\"", ",", "m", ".", "server", ".", "Addr", ")", "\n", "err", ":=", "m", ".", "server", ".", "Shutdo...
// Shutdown the server
[ "Shutdown", "the", "server" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/router/module.go#L77-L83
149,445
octavore/nagax
router/module.go
POST
func (m *Module) POST(path string, h Handle) { m.HTTPRouter.POST(path, m.wrap(h)) }
go
func (m *Module) POST(path string, h Handle) { m.HTTPRouter.POST(path, m.wrap(h)) }
[ "func", "(", "m", "*", "Module", ")", "POST", "(", "path", "string", ",", "h", "Handle", ")", "{", "m", ".", "HTTPRouter", ".", "POST", "(", "path", ",", "m", ".", "wrap", "(", "h", ")", ")", "\n", "}" ]
// POST is a shortcut for m.HTTPRouter.POST
[ "POST", "is", "a", "shortcut", "for", "m", ".", "HTTPRouter", ".", "POST" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/router/module.go#L101-L103
149,446
octavore/nagax
router/module.go
Handle
func (m *Module) Handle(method, path string, h http.HandlerFunc) { m.HTTPRouter.Handle(method, path, func(rw http.ResponseWriter, req *http.Request, _ Params) { h(rw, req) }) }
go
func (m *Module) Handle(method, path string, h http.HandlerFunc) { m.HTTPRouter.Handle(method, path, func(rw http.ResponseWriter, req *http.Request, _ Params) { h(rw, req) }) }
[ "func", "(", "m", "*", "Module", ")", "Handle", "(", "method", ",", "path", "string", ",", "h", "http", ".", "HandlerFunc", ")", "{", "m", ".", "HTTPRouter", ".", "Handle", "(", "method", ",", "path", ",", "func", "(", "rw", "http", ".", "ResponseW...
// Handle is a shortcut for m.HTTPRouter.Handle
[ "Handle", "is", "a", "shortcut", "for", "m", ".", "HTTPRouter", ".", "Handle" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/router/module.go#L126-L130
149,447
octavore/nagax
router/module.go
WrappedHandle
func (m *Module) WrappedHandle(method, path string, h Handle) { m.HTTPRouter.Handle(method, path, m.wrap(h)) }
go
func (m *Module) WrappedHandle(method, path string, h Handle) { m.HTTPRouter.Handle(method, path, m.wrap(h)) }
[ "func", "(", "m", "*", "Module", ")", "WrappedHandle", "(", "method", ",", "path", "string", ",", "h", "Handle", ")", "{", "m", ".", "HTTPRouter", ".", "Handle", "(", "method", ",", "path", ",", "m", ".", "wrap", "(", "h", ")", ")", "\n", "}" ]
// WrappedHandle is a shortcut for m.HTTPRouter.Handle
[ "WrappedHandle", "is", "a", "shortcut", "for", "m", ".", "HTTPRouter", ".", "Handle" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/router/module.go#L133-L135
149,448
octavore/nagax
router/module.go
Subrouter
func (m *Module) Subrouter(path string) *httprouter.Router { r := httprouter.New() m.Root.Handle(path, r) return r }
go
func (m *Module) Subrouter(path string) *httprouter.Router { r := httprouter.New() m.Root.Handle(path, r) return r }
[ "func", "(", "m", "*", "Module", ")", "Subrouter", "(", "path", "string", ")", "*", "httprouter", ".", "Router", "{", "r", ":=", "httprouter", ".", "New", "(", ")", "\n", "m", ".", "Root", ".", "Handle", "(", "path", ",", "r", ")", "\n", "return"...
// Subrouter creates a new router rooted at path
[ "Subrouter", "creates", "a", "new", "router", "rooted", "at", "path" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/router/module.go#L138-L142
149,449
octavore/nagax
router/module.go
wrap
func (m *Module) wrap(h Handle) httprouter.Handle { return func(rw http.ResponseWriter, req *http.Request, par Params) { err := h(rw, req, par) if err != nil && m.ErrorHandler != nil { m.ErrorHandler(rw, req, err) } } }
go
func (m *Module) wrap(h Handle) httprouter.Handle { return func(rw http.ResponseWriter, req *http.Request, par Params) { err := h(rw, req, par) if err != nil && m.ErrorHandler != nil { m.ErrorHandler(rw, req, err) } } }
[ "func", "(", "m", "*", "Module", ")", "wrap", "(", "h", "Handle", ")", "httprouter", ".", "Handle", "{", "return", "func", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "par", "Params", ")", "{", "err", ":=...
// wrap the given handler to handle errors
[ "wrap", "the", "given", "handler", "to", "handle", "errors" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/router/module.go#L145-L152
149,450
octavore/nagax
users/session/destroy.go
DestroySession
func (m *Module) DestroySession(rw http.ResponseWriter, req *http.Request) { session, err := m.getSessionFromRequest(req) if session == nil { return } else if err != nil { // TODO: log error return } m.RevocationStore.Revoke(session.SessionID, m.revocationTrackDuration) http.SetCookie(rw, &http.Cookie{ N...
go
func (m *Module) DestroySession(rw http.ResponseWriter, req *http.Request) { session, err := m.getSessionFromRequest(req) if session == nil { return } else if err != nil { // TODO: log error return } m.RevocationStore.Revoke(session.SessionID, m.revocationTrackDuration) http.SetCookie(rw, &http.Cookie{ N...
[ "func", "(", "m", "*", "Module", ")", "DestroySession", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "session", ",", "err", ":=", "m", ".", "getSessionFromRequest", "(", "req", ")", "\n", "if", "session",...
// DestroySession handles a logout request and attempts to erase the session cookie.
[ "DestroySession", "handles", "a", "logout", "request", "and", "attempts", "to", "erase", "the", "session", "cookie", "." ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/session/destroy.go#L9-L29
149,451
octavore/nagax
users/oauth/provider.go
HandleOAuthStart
func (p *Provider) HandleOAuthStart(rw http.ResponseWriter, req *http.Request, par router.Params) error { var state string if p.SetOAuthState != nil { rawState, err := p.SetOAuthState(req, par) if err != nil { return errors.Wrap(err) } state = base64.StdEncoding.EncodeToString([]byte(rawState)) } url := ...
go
func (p *Provider) HandleOAuthStart(rw http.ResponseWriter, req *http.Request, par router.Params) error { var state string if p.SetOAuthState != nil { rawState, err := p.SetOAuthState(req, par) if err != nil { return errors.Wrap(err) } state = base64.StdEncoding.EncodeToString([]byte(rawState)) } url := ...
[ "func", "(", "p", "*", "Provider", ")", "HandleOAuthStart", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "par", "router", ".", "Params", ")", "error", "{", "var", "state", "string", "\n", "if", "p", ".", "Se...
// HandleOAuthStart is the handler for redirecting to the oauth provider.
[ "HandleOAuthStart", "is", "the", "handler", "for", "redirecting", "to", "the", "oauth", "provider", "." ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/oauth/provider.go#L37-L49
149,452
octavore/nagax
users/oauth/provider.go
handleCallback
func (p *Provider) handleCallback(rw http.ResponseWriter, req *http.Request, _ router.Params) error { // oauth handshake code := req.FormValue("code") accessToken, err := p.Config.Exchange(oauth2.NoContext, code) if err != nil { return errors.Wrap(err) } var state string encState := req.FormValue("state") if ...
go
func (p *Provider) handleCallback(rw http.ResponseWriter, req *http.Request, _ router.Params) error { // oauth handshake code := req.FormValue("code") accessToken, err := p.Config.Exchange(oauth2.NoContext, code) if err != nil { return errors.Wrap(err) } var state string encState := req.FormValue("state") if ...
[ "func", "(", "p", "*", "Provider", ")", "handleCallback", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "_", "router", ".", "Params", ")", "error", "{", "// oauth handshake", "code", ":=", "req", ".", "FormValue"...
// doCallback parses the oauth callback and state if valid, and then calls PostCallback
[ "doCallback", "parses", "the", "oauth", "callback", "and", "state", "if", "valid", "and", "then", "calls", "PostCallback" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/oauth/provider.go#L52-L73
149,453
octavore/nagax
users/oauth/provider.go
Client
func (p *Provider) Client(ctx context.Context, t *oauth2.Token) *http.Client { if p.NewClient != nil { return p.NewClient(ctx, t) } return p.Config.Client(ctx, t) }
go
func (p *Provider) Client(ctx context.Context, t *oauth2.Token) *http.Client { if p.NewClient != nil { return p.NewClient(ctx, t) } return p.Config.Client(ctx, t) }
[ "func", "(", "p", "*", "Provider", ")", "Client", "(", "ctx", "context", ".", "Context", ",", "t", "*", "oauth2", ".", "Token", ")", "*", "http", ".", "Client", "{", "if", "p", ".", "NewClient", "!=", "nil", "{", "return", "p", ".", "NewClient", ...
// Client returns a new http client for authenticated requests. Provider // can be configured with NewClient to override the default oauth2.Config.Client.
[ "Client", "returns", "a", "new", "http", "client", "for", "authenticated", "requests", ".", "Provider", "can", "be", "configured", "with", "NewClient", "to", "override", "the", "default", "oauth2", ".", "Config", ".", "Client", "." ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/oauth/provider.go#L77-L82
149,454
octavore/nagax
users/session/verify_request.go
Verify
func (m *Module) Verify(req *http.Request) (string, error) { session, err := m.getSessionFromRequest(req) if err != nil { return "", err } else if session == nil { return "", nil } return session.ID, nil }
go
func (m *Module) Verify(req *http.Request) (string, error) { session, err := m.getSessionFromRequest(req) if err != nil { return "", err } else if session == nil { return "", nil } return session.ID, nil }
[ "func", "(", "m", "*", "Module", ")", "Verify", "(", "req", "*", "http", ".", "Request", ")", "(", "string", ",", "error", ")", "{", "session", ",", "err", ":=", "m", ".", "getSessionFromRequest", "(", "req", ")", "\n", "if", "err", "!=", "nil", ...
// Verify a request with a cookie
[ "Verify", "a", "request", "with", "a", "cookie" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/session/verify_request.go#L6-L14
149,455
octavore/nagax
users/session/verify_request.go
VerifyAndExtend
func (m *Module) VerifyAndExtend(rw http.ResponseWriter, req *http.Request) (string, error) { session, err := m.getSessionFromRequest(req) if err != nil { return "", err } else if session == nil { return "", nil } cookie, err := m.newSessionCookie(session) if err == nil { rw.Header().Add("Set-Cookie", cook...
go
func (m *Module) VerifyAndExtend(rw http.ResponseWriter, req *http.Request) (string, error) { session, err := m.getSessionFromRequest(req) if err != nil { return "", err } else if session == nil { return "", nil } cookie, err := m.newSessionCookie(session) if err == nil { rw.Header().Add("Set-Cookie", cook...
[ "func", "(", "m", "*", "Module", ")", "VerifyAndExtend", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "(", "string", ",", "error", ")", "{", "session", ",", "err", ":=", "m", ".", "getSessionFromRequest", "(",...
// VerifyAndExtend authenticates a cookie based session and // refreshes the validity period. Returns an error if there // was a cookie but it was invalid
[ "VerifyAndExtend", "authenticates", "a", "cookie", "based", "session", "and", "refreshes", "the", "validity", "period", ".", "Returns", "an", "error", "if", "there", "was", "a", "cookie", "but", "it", "was", "invalid" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/session/verify_request.go#L19-L33
149,456
octavore/nagax
migrate/module.go
Init
func (m *Module) Init(c *service.Config) { m.registerCommands(c) c.Setup = func() error { m.env = c.Env() m.backoff = &backoff.StopBackOff{} err := m.Config.ReadConfig(&m.config) if m.config.MigrationsTable != "" { migrate.SetTable(m.config.MigrationsTable) } return err } }
go
func (m *Module) Init(c *service.Config) { m.registerCommands(c) c.Setup = func() error { m.env = c.Env() m.backoff = &backoff.StopBackOff{} err := m.Config.ReadConfig(&m.config) if m.config.MigrationsTable != "" { migrate.SetTable(m.config.MigrationsTable) } return err } }
[ "func", "(", "m", "*", "Module", ")", "Init", "(", "c", "*", "service", ".", "Config", ")", "{", "m", ".", "registerCommands", "(", "c", ")", "\n\n", "c", ".", "Setup", "=", "func", "(", ")", "error", "{", "m", ".", "env", "=", "c", ".", "Env...
// Init the migrate module
[ "Init", "the", "migrate", "module" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/migrate/module.go#L47-L59
149,457
octavore/nagax
migrate/module.go
ConnectDefault
func (m *Module) ConnectDefault() (*sql.DB, error) { ds, err := m.GetBackend(m.env.String()) if err != nil { return nil, err } return ds.Connect() }
go
func (m *Module) ConnectDefault() (*sql.DB, error) { ds, err := m.GetBackend(m.env.String()) if err != nil { return nil, err } return ds.Connect() }
[ "func", "(", "m", "*", "Module", ")", "ConnectDefault", "(", ")", "(", "*", "sql", ".", "DB", ",", "error", ")", "{", "ds", ",", "err", ":=", "m", ".", "GetBackend", "(", "m", ".", "env", ".", "String", "(", ")", ")", "\n", "if", "err", "!=",...
// ConnectDefault to the DB with name specified by env
[ "ConnectDefault", "to", "the", "DB", "with", "name", "specified", "by", "env" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/migrate/module.go#L62-L68
149,458
octavore/nagax
migrate/module.go
Connect
func (d *Datasource) Connect() (*sql.DB, error) { return sql.Open(d.Driver, d.DSN) }
go
func (d *Datasource) Connect() (*sql.DB, error) { return sql.Open(d.Driver, d.DSN) }
[ "func", "(", "d", "*", "Datasource", ")", "Connect", "(", ")", "(", "*", "sql", ".", "DB", ",", "error", ")", "{", "return", "sql", ".", "Open", "(", "d", ".", "Driver", ",", "d", ".", "DSN", ")", "\n", "}" ]
// Connect is a helper function to connect to this datasource
[ "Connect", "is", "a", "helper", "function", "to", "connect", "to", "this", "datasource" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/migrate/module.go#L71-L73
149,459
octavore/nagax
migrate/module.go
migrate
func (d *Datasource) migrate(m migrate.MigrationSource) error { db, err := d.Connect() if err != nil { return err } defer db.Close() _, err = migrate.Exec(db, d.Driver, m, migrate.Up) return err }
go
func (d *Datasource) migrate(m migrate.MigrationSource) error { db, err := d.Connect() if err != nil { return err } defer db.Close() _, err = migrate.Exec(db, d.Driver, m, migrate.Up) return err }
[ "func", "(", "d", "*", "Datasource", ")", "migrate", "(", "m", "migrate", ".", "MigrationSource", ")", "error", "{", "db", ",", "err", ":=", "d", ".", "Connect", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "de...
// Migrate runs migrations in m
[ "Migrate", "runs", "migrations", "in", "m" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/migrate/module.go#L76-L84
149,460
bartmeuris/progressio
progress.go
String
func (p *Progress) String() string { timeS := fmt.Sprintf(" (Time: %s", FormatDuration(time.Since(p.StartTime))) // Build the Speed string speedS := "" if p.Speed > 0 { speedS = fmt.Sprintf(" (Speed: %s", FormatSize(IEC, p.Speed, true)) + "/s" } if p.SpeedAvg > 0 { if len(speedS) > 0 { speedS += " / AVG: "...
go
func (p *Progress) String() string { timeS := fmt.Sprintf(" (Time: %s", FormatDuration(time.Since(p.StartTime))) // Build the Speed string speedS := "" if p.Speed > 0 { speedS = fmt.Sprintf(" (Speed: %s", FormatSize(IEC, p.Speed, true)) + "/s" } if p.SpeedAvg > 0 { if len(speedS) > 0 { speedS += " / AVG: "...
[ "func", "(", "p", "*", "Progress", ")", "String", "(", ")", "string", "{", "timeS", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "FormatDuration", "(", "time", ".", "Since", "(", "p", ".", "StartTime", ")", ")", ")", "\n", "// Build the Speed s...
// String returns a string representation of the progress. It takes into account // if the size was known, and only tries to display relevant data.
[ "String", "returns", "a", "string", "representation", "of", "the", "progress", ".", "It", "takes", "into", "account", "if", "the", "size", "was", "known", "and", "only", "tries", "to", "display", "relevant", "data", "." ]
387f5796a6e8b84e8f9b3c1c0a97769b6b83adac
https://github.com/bartmeuris/progressio/blob/387f5796a6e8b84e8f9b3c1c0a97769b6b83adac/progress.go#L101-L148
149,461
octavore/nagax
util/errors/errors.go
New
func New(m string, a ...interface{}) error { return errors.Wrap(fmt.Errorf(m, a...), 1) }
go
func New(m string, a ...interface{}) error { return errors.Wrap(fmt.Errorf(m, a...), 1) }
[ "func", "New", "(", "m", "string", ",", "a", "...", "interface", "{", "}", ")", "error", "{", "return", "errors", ".", "Wrap", "(", "fmt", ".", "Errorf", "(", "m", ",", "a", "...", ")", ",", "1", ")", "\n", "}" ]
// New returns a new wrapped error with m as message
[ "New", "returns", "a", "new", "wrapped", "error", "with", "m", "as", "message" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/util/errors/errors.go#L11-L13
149,462
octavore/nagax
util/errors/errors.go
Wrap
func Wrap(e error) error { if e == nil { return nil } return errors.Wrap(e, 1) }
go
func Wrap(e error) error { if e == nil { return nil } return errors.Wrap(e, 1) }
[ "func", "Wrap", "(", "e", "error", ")", "error", "{", "if", "e", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "errors", ".", "Wrap", "(", "e", ",", "1", ")", "\n", "}" ]
// Wrap an error e if it is not nil
[ "Wrap", "an", "error", "e", "if", "it", "is", "not", "nil" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/util/errors/errors.go#L16-L21
149,463
octavore/nagax
util/errors/errors.go
WrapS
func WrapS(e error, skip int) error { if e == nil { return nil } return errors.Wrap(e, skip+1) }
go
func WrapS(e error, skip int) error { if e == nil { return nil } return errors.Wrap(e, skip+1) }
[ "func", "WrapS", "(", "e", "error", ",", "skip", "int", ")", "error", "{", "if", "e", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "errors", ".", "Wrap", "(", "e", ",", "skip", "+", "1", ")", "\n", "}" ]
// WrapS is like Wrap but skips 'skip' lines of trace
[ "WrapS", "is", "like", "Wrap", "but", "skips", "skip", "lines", "of", "trace" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/util/errors/errors.go#L24-L29
149,464
octavore/nagax
users/tokenauth/options.go
WithPrefix
func WithPrefix(prefix string) option { return func(m *Module) { m.prefix = strings.ToLower(prefix) } }
go
func WithPrefix(prefix string) option { return func(m *Module) { m.prefix = strings.ToLower(prefix) } }
[ "func", "WithPrefix", "(", "prefix", "string", ")", "option", "{", "return", "func", "(", "m", "*", "Module", ")", "{", "m", ".", "prefix", "=", "strings", ".", "ToLower", "(", "prefix", ")", "\n", "}", "\n", "}" ]
// WithPrefix sets the prefix to check for in the header. Defaults to 'Token'. Optional.
[ "WithPrefix", "sets", "the", "prefix", "to", "check", "for", "in", "the", "header", ".", "Defaults", "to", "Token", ".", "Optional", "." ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/tokenauth/options.go#L30-L34
149,465
octavore/nagax
migrate/migrations.go
SetMigrationSource
func (m *Module) SetMigrationSource(asset assetFunc, assetDir assetDirFunc, dir string) { m.migrationSource = &migrate.AssetMigrationSource{ Asset: asset, AssetDir: assetDir, Dir: dir, } }
go
func (m *Module) SetMigrationSource(asset assetFunc, assetDir assetDirFunc, dir string) { m.migrationSource = &migrate.AssetMigrationSource{ Asset: asset, AssetDir: assetDir, Dir: dir, } }
[ "func", "(", "m", "*", "Module", ")", "SetMigrationSource", "(", "asset", "assetFunc", ",", "assetDir", "assetDirFunc", ",", "dir", "string", ")", "{", "m", ".", "migrationSource", "=", "&", "migrate", ".", "AssetMigrationSource", "{", "Asset", ":", "asset",...
// SetMigrationSource sets the migration source, for compatibility with // embedded file assets.
[ "SetMigrationSource", "sets", "the", "migration", "source", "for", "compatibility", "with", "embedded", "file", "assets", "." ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/migrate/migrations.go#L16-L22
149,466
octavore/nagax
migrate/migrations.go
getMigrationSource
func (m *Module) getMigrationSource() (migrate.MigrationSource, error) { if m.migrationSource != nil { return m.migrationSource, nil } configPath, err := filepath.Abs(m.Config.ConfigPath) if err != nil { return nil, err } migrationPath := filepath.Join(filepath.Dir(configPath), m.config.MigrationsDir) return...
go
func (m *Module) getMigrationSource() (migrate.MigrationSource, error) { if m.migrationSource != nil { return m.migrationSource, nil } configPath, err := filepath.Abs(m.Config.ConfigPath) if err != nil { return nil, err } migrationPath := filepath.Join(filepath.Dir(configPath), m.config.MigrationsDir) return...
[ "func", "(", "m", "*", "Module", ")", "getMigrationSource", "(", ")", "(", "migrate", ".", "MigrationSource", ",", "error", ")", "{", "if", "m", ".", "migrationSource", "!=", "nil", "{", "return", "m", ".", "migrationSource", ",", "nil", "\n", "}", "\n...
// getMigrationSource returns the m.migrationSource if set, otherwise // it defaults by reading from the MigrationsDir specified in
[ "getMigrationSource", "returns", "the", "m", ".", "migrationSource", "if", "set", "otherwise", "it", "defaults", "by", "reading", "from", "the", "MigrationsDir", "specified", "in" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/migrate/migrations.go#L26-L36
149,467
octavore/nagax
router/errors.go
newAPIError
func newAPIError(code int32, detail string) api.Error { codeEnum := api.ErrorCode(code) _, ok := api.ErrorCode_name[code] if !ok { if code >= 400 && code < 499 { code = int32(api.ErrorCode_bad_request) } else { code = int32(api.ErrorCode_internal_server_error) } codeEnum = api.ErrorCode(code) } retur...
go
func newAPIError(code int32, detail string) api.Error { codeEnum := api.ErrorCode(code) _, ok := api.ErrorCode_name[code] if !ok { if code >= 400 && code < 499 { code = int32(api.ErrorCode_bad_request) } else { code = int32(api.ErrorCode_internal_server_error) } codeEnum = api.ErrorCode(code) } retur...
[ "func", "newAPIError", "(", "code", "int32", ",", "detail", "string", ")", "api", ".", "Error", "{", "codeEnum", ":=", "api", ".", "ErrorCode", "(", "code", ")", "\n", "_", ",", "ok", ":=", "api", ".", "ErrorCode_name", "[", "code", "]", "\n", "if", ...
// newError creates an Error with the appropriate enum for the code.
[ "newError", "creates", "an", "Error", "with", "the", "appropriate", "enum", "for", "the", "code", "." ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/router/errors.go#L54-L70
149,468
octavore/nagax
router/errors.go
NewRequestError
func NewRequestError(req *http.Request, code int32, detail string) error { return &Error{ silent: false, redirect: false, source: req.URL.String(), request: req, err: newAPIError(code, detail), } }
go
func NewRequestError(req *http.Request, code int32, detail string) error { return &Error{ silent: false, redirect: false, source: req.URL.String(), request: req, err: newAPIError(code, detail), } }
[ "func", "NewRequestError", "(", "req", "*", "http", ".", "Request", ",", "code", "int32", ",", "detail", "string", ")", "error", "{", "return", "&", "Error", "{", "silent", ":", "false", ",", "redirect", ":", "false", ",", "source", ":", "req", ".", ...
// NewRequestError creates an Error with source set to the request url
[ "NewRequestError", "creates", "an", "Error", "with", "source", "set", "to", "the", "request", "url" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/router/errors.go#L73-L81
149,469
octavore/nagax
router/errors.go
NewQuietError
func NewQuietError(req *http.Request, code int32, e error) error { return errors.Wrap(&Error{ silent: true, redirect: false, source: req.URL.String(), request: req, err: newAPIError(code, errString(e)), }, 1) }
go
func NewQuietError(req *http.Request, code int32, e error) error { return errors.Wrap(&Error{ silent: true, redirect: false, source: req.URL.String(), request: req, err: newAPIError(code, errString(e)), }, 1) }
[ "func", "NewQuietError", "(", "req", "*", "http", ".", "Request", ",", "code", "int32", ",", "e", "error", ")", "error", "{", "return", "errors", ".", "Wrap", "(", "&", "Error", "{", "silent", ":", "true", ",", "redirect", ":", "false", ",", "source"...
// NewQuietError logs the error but does not show it to the user
[ "NewQuietError", "logs", "the", "error", "but", "does", "not", "show", "it", "to", "the", "user" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/router/errors.go#L95-L103
149,470
octavore/nagax
router/errors.go
HandleError
func (m *Module) HandleError(rw http.ResponseWriter, req *http.Request, err error) int { switch err { case ErrNotFound: err = NewRequestError(req, http.StatusNotFound, "not found: "+req.URL.String()) case ErrNotAuthorized: err = NewRequestError(req, http.StatusUnauthorized, "not authenticated") case ErrForbidde...
go
func (m *Module) HandleError(rw http.ResponseWriter, req *http.Request, err error) int { switch err { case ErrNotFound: err = NewRequestError(req, http.StatusNotFound, "not found: "+req.URL.String()) case ErrNotAuthorized: err = NewRequestError(req, http.StatusUnauthorized, "not authenticated") case ErrForbidde...
[ "func", "(", "m", "*", "Module", ")", "HandleError", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "err", "error", ")", "int", "{", "switch", "err", "{", "case", "ErrNotFound", ":", "err", "=", "NewRequestError...
// HandleError is the default error handler
[ "HandleError", "is", "the", "default", "error", "handler" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/router/errors.go#L118-L164
149,471
octavore/nagax
router/errors.go
errString
func errString(err error) string { e, ok := err.(*errors.Error) if !ok { return err.Error() } s := e.StackFrames()[0] f := path.Base(s.File) prefix := fmt.Sprintf("[%s/%s:%d]", s.Package, f, s.LineNumber) if e.Error() == "" { return prefix } return fmt.Sprint(prefix, " ", e.Error()) }
go
func errString(err error) string { e, ok := err.(*errors.Error) if !ok { return err.Error() } s := e.StackFrames()[0] f := path.Base(s.File) prefix := fmt.Sprintf("[%s/%s:%d]", s.Package, f, s.LineNumber) if e.Error() == "" { return prefix } return fmt.Sprint(prefix, " ", e.Error()) }
[ "func", "errString", "(", "err", "error", ")", "string", "{", "e", ",", "ok", ":=", "err", ".", "(", "*", "errors", ".", "Error", ")", "\n", "if", "!", "ok", "{", "return", "err", ".", "Error", "(", ")", "\n", "}", "\n", "s", ":=", "e", ".", ...
// errString prints out an error, with its location if appropriate
[ "errString", "prints", "out", "an", "error", "with", "its", "location", "if", "appropriate" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/router/errors.go#L180-L192
149,472
bartmeuris/progressio
progresswriter.go
NewProgressWriter
func NewProgressWriter(w io.Writer, size int64) (*ProgressWriter, <-chan Progress) { if w == nil { return nil, nil } wc, ok := w.(io.WriteCloser) if !ok { wc = getNopWriteCloser(w) } ret := &ProgressWriter{wc, *mkIoProgress(size)} return ret, ret.ch }
go
func NewProgressWriter(w io.Writer, size int64) (*ProgressWriter, <-chan Progress) { if w == nil { return nil, nil } wc, ok := w.(io.WriteCloser) if !ok { wc = getNopWriteCloser(w) } ret := &ProgressWriter{wc, *mkIoProgress(size)} return ret, ret.ch }
[ "func", "NewProgressWriter", "(", "w", "io", ".", "Writer", ",", "size", "int64", ")", "(", "*", "ProgressWriter", ",", "<-", "chan", "Progress", ")", "{", "if", "w", "==", "nil", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "wc", ",", "ok", ...
// NewProgressWriter creates a new ProgressWriter object based on the io.Writer and the // size you specified. Specify a size <= 0 if you don't know the size.
[ "NewProgressWriter", "creates", "a", "new", "ProgressWriter", "object", "based", "on", "the", "io", ".", "Writer", "and", "the", "size", "you", "specified", ".", "Specify", "a", "size", "<", "=", "0", "if", "you", "don", "t", "know", "the", "size", "." ]
387f5796a6e8b84e8f9b3c1c0a97769b6b83adac
https://github.com/bartmeuris/progressio/blob/387f5796a6e8b84e8f9b3c1c0a97769b6b83adac/progresswriter.go#L22-L32
149,473
bartmeuris/progressio
progresswriter.go
Write
func (p *ProgressWriter) Write(b []byte) (n int, err error) { n, err = p.w.Write(b[0:]) p.updateProgress(int64(n)) return }
go
func (p *ProgressWriter) Write(b []byte) (n int, err error) { n, err = p.w.Write(b[0:]) p.updateProgress(int64(n)) return }
[ "func", "(", "p", "*", "ProgressWriter", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "n", ",", "err", "=", "p", ".", "w", ".", "Write", "(", "b", "[", "0", ":", "]", ")", "\n", "p", ".", ...
// Write wraps the io.Writer Write function to also update the progress.
[ "Write", "wraps", "the", "io", ".", "Writer", "Write", "function", "to", "also", "update", "the", "progress", "." ]
387f5796a6e8b84e8f9b3c1c0a97769b6b83adac
https://github.com/bartmeuris/progressio/blob/387f5796a6e8b84e8f9b3c1c0a97769b6b83adac/progresswriter.go#L35-L39
149,474
bartmeuris/progressio
progresswriter.go
Close
func (p *ProgressWriter) Close() (err error) { err = p.w.Close() p.stopProgress() return }
go
func (p *ProgressWriter) Close() (err error) { err = p.w.Close() p.stopProgress() return }
[ "func", "(", "p", "*", "ProgressWriter", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "err", "=", "p", ".", "w", ".", "Close", "(", ")", "\n", "p", ".", "stopProgress", "(", ")", "\n", "return", "\n", "}" ]
// Close wraps the io.WriterCloser Close function to clean up everything. ProgressWriter // objects should always be closed to make sure everything is cleaned up.
[ "Close", "wraps", "the", "io", ".", "WriterCloser", "Close", "function", "to", "clean", "up", "everything", ".", "ProgressWriter", "objects", "should", "always", "be", "closed", "to", "make", "sure", "everything", "is", "cleaned", "up", "." ]
387f5796a6e8b84e8f9b3c1c0a97769b6b83adac
https://github.com/bartmeuris/progressio/blob/387f5796a6e8b84e8f9b3c1c0a97769b6b83adac/progresswriter.go#L43-L47
149,475
octavore/nagax
users/databaseauth/module.go
Login
func (m *Module) Login(email, password string) (string, bool, error) { email = strings.ToLower(email) userID, hashedPassword, err := m.userStore.Get(email) if err != nil { return "", false, err } return userID, AuthenticatePassword(password, hashedPassword), nil }
go
func (m *Module) Login(email, password string) (string, bool, error) { email = strings.ToLower(email) userID, hashedPassword, err := m.userStore.Get(email) if err != nil { return "", false, err } return userID, AuthenticatePassword(password, hashedPassword), nil }
[ "func", "(", "m", "*", "Module", ")", "Login", "(", "email", ",", "password", "string", ")", "(", "string", ",", "bool", ",", "error", ")", "{", "email", "=", "strings", ".", "ToLower", "(", "email", ")", "\n", "userID", ",", "hashedPassword", ",", ...
// Login with email and password, returns user id if valid
[ "Login", "with", "email", "and", "password", "returns", "user", "id", "if", "valid" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/databaseauth/module.go#L64-L71
149,476
octavore/nagax
migrate/backend.go
GetBackend
func (m *Module) GetBackend(dbname string) (backend, error) { ds, ok := m.config.Datasources[dbname] if !ok { return nil, fmt.Errorf("migrate: %q not configured", dbname) } migrations, err := m.getMigrationSource() if err != nil { return nil, err } // special case for parallelizing tests: add a suffix to t...
go
func (m *Module) GetBackend(dbname string) (backend, error) { ds, ok := m.config.Datasources[dbname] if !ok { return nil, fmt.Errorf("migrate: %q not configured", dbname) } migrations, err := m.getMigrationSource() if err != nil { return nil, err } // special case for parallelizing tests: add a suffix to t...
[ "func", "(", "m", "*", "Module", ")", "GetBackend", "(", "dbname", "string", ")", "(", "backend", ",", "error", ")", "{", "ds", ",", "ok", ":=", "m", ".", "config", ".", "Datasources", "[", "dbname", "]", "\n", "if", "!", "ok", "{", "return", "ni...
// GetBackend selects the datasource identified by dbname in the config file and // initializes the correct type of backend.
[ "GetBackend", "selects", "the", "datasource", "identified", "by", "dbname", "in", "the", "config", "file", "and", "initializes", "the", "correct", "type", "of", "backend", "." ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/migrate/backend.go#L19-L50
149,477
octavore/nagax
static/options.go
WithBox
func WithBox(box fileSource) option { return func(m *Module) { if m.box != nil { panic("box already configured for static module") } m.box = box } }
go
func WithBox(box fileSource) option { return func(m *Module) { if m.box != nil { panic("box already configured for static module") } m.box = box } }
[ "func", "WithBox", "(", "box", "fileSource", ")", "option", "{", "return", "func", "(", "m", "*", "Module", ")", "{", "if", "m", ".", "box", "!=", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "m", ".", "box", "=", "box", "\n", ...
// WithBox configures the static module with a source
[ "WithBox", "configures", "the", "static", "module", "with", "a", "source" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/static/options.go#L10-L17
149,478
octavore/nagax
static/options.go
WithHandle404
func WithHandle404(fn http.HandlerFunc) option { return func(m *Module) { m.handle404 = fn } }
go
func WithHandle404(fn http.HandlerFunc) option { return func(m *Module) { m.handle404 = fn } }
[ "func", "WithHandle404", "(", "fn", "http", ".", "HandlerFunc", ")", "option", "{", "return", "func", "(", "m", "*", "Module", ")", "{", "m", ".", "handle404", "=", "fn", "\n", "}", "\n", "}" ]
// WithHandle404 configures static module with a base URL path for // serving static assets
[ "WithHandle404", "configures", "static", "module", "with", "a", "base", "URL", "path", "for", "serving", "static", "assets" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/static/options.go#L37-L41
149,479
octavore/nagax
static/options.go
WithHandle500
func WithHandle500(fn func(rw http.ResponseWriter, req *http.Request, err error)) option { return func(m *Module) { m.handle500 = fn } }
go
func WithHandle500(fn func(rw http.ResponseWriter, req *http.Request, err error)) option { return func(m *Module) { m.handle500 = fn } }
[ "func", "WithHandle500", "(", "fn", "func", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "err", "error", ")", ")", "option", "{", "return", "func", "(", "m", "*", "Module", ")", "{", "m", ".", "handle500", ...
// WithHandle500 configures static module with a base URL path for // serving static assets
[ "WithHandle500", "configures", "static", "module", "with", "a", "base", "URL", "path", "for", "serving", "static", "assets" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/static/options.go#L45-L49
149,480
bartmeuris/progressio
progressreader.go
NewProgressFileReader
func NewProgressFileReader(file string) (*ProgressReader, <-chan Progress, error) { f, ferr := os.Open(file) if ferr != nil { return nil, nil, ferr } // Get the filesize by seeking to the end of the file, and back to offset 0 fsize, err := f.Seek(0, os.SEEK_END) if err != nil { return nil, nil, err } if _, ...
go
func NewProgressFileReader(file string) (*ProgressReader, <-chan Progress, error) { f, ferr := os.Open(file) if ferr != nil { return nil, nil, ferr } // Get the filesize by seeking to the end of the file, and back to offset 0 fsize, err := f.Seek(0, os.SEEK_END) if err != nil { return nil, nil, err } if _, ...
[ "func", "NewProgressFileReader", "(", "file", "string", ")", "(", "*", "ProgressReader", ",", "<-", "chan", "Progress", ",", "error", ")", "{", "f", ",", "ferr", ":=", "os", ".", "Open", "(", "file", ")", "\n", "if", "ferr", "!=", "nil", "{", "return...
// NewProgressFileReader creates a new ProgressReader based on a file. It teturns a // ProgressReader object and a channel on success, or an error on failure.
[ "NewProgressFileReader", "creates", "a", "new", "ProgressReader", "based", "on", "a", "file", ".", "It", "teturns", "a", "ProgressReader", "object", "and", "a", "channel", "on", "success", "or", "an", "error", "on", "failure", "." ]
387f5796a6e8b84e8f9b3c1c0a97769b6b83adac
https://github.com/bartmeuris/progressio/blob/387f5796a6e8b84e8f9b3c1c0a97769b6b83adac/progressreader.go#L18-L33
149,481
bartmeuris/progressio
progressreader.go
NewProgressReader
func NewProgressReader(r io.Reader, size int64) (*ProgressReader, <-chan Progress) { if r == nil { return nil, nil } rc, ok := r.(io.ReadCloser) if !ok { rc = ioutil.NopCloser(r) } ret := &ProgressReader{rc, *mkIoProgress(size)} return ret, ret.ch }
go
func NewProgressReader(r io.Reader, size int64) (*ProgressReader, <-chan Progress) { if r == nil { return nil, nil } rc, ok := r.(io.ReadCloser) if !ok { rc = ioutil.NopCloser(r) } ret := &ProgressReader{rc, *mkIoProgress(size)} return ret, ret.ch }
[ "func", "NewProgressReader", "(", "r", "io", ".", "Reader", ",", "size", "int64", ")", "(", "*", "ProgressReader", ",", "<-", "chan", "Progress", ")", "{", "if", "r", "==", "nil", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "rc", ",", "ok", ...
// NewProgressReader creates a new ProgressReader object based on the io.Reader and the // size you specified. Specify a size <= 0 if you don't know the size.
[ "NewProgressReader", "creates", "a", "new", "ProgressReader", "object", "based", "on", "the", "io", ".", "Reader", "and", "the", "size", "you", "specified", ".", "Specify", "a", "size", "<", "=", "0", "if", "you", "don", "t", "know", "the", "size", "." ]
387f5796a6e8b84e8f9b3c1c0a97769b6b83adac
https://github.com/bartmeuris/progressio/blob/387f5796a6e8b84e8f9b3c1c0a97769b6b83adac/progressreader.go#L37-L47
149,482
bartmeuris/progressio
progressreader.go
Read
func (p *ProgressReader) Read(b []byte) (n int, err error) { n, err = p.r.Read(b) p.updateProgress(int64(n)) return }
go
func (p *ProgressReader) Read(b []byte) (n int, err error) { n, err = p.r.Read(b) p.updateProgress(int64(n)) return }
[ "func", "(", "p", "*", "ProgressReader", ")", "Read", "(", "b", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "n", ",", "err", "=", "p", ".", "r", ".", "Read", "(", "b", ")", "\n", "p", ".", "updateProgress", "(", "...
// Read wraps the io.Reader Read function to also update the progress.
[ "Read", "wraps", "the", "io", ".", "Reader", "Read", "function", "to", "also", "update", "the", "progress", "." ]
387f5796a6e8b84e8f9b3c1c0a97769b6b83adac
https://github.com/bartmeuris/progressio/blob/387f5796a6e8b84e8f9b3c1c0a97769b6b83adac/progressreader.go#L50-L54
149,483
bartmeuris/progressio
progressreader.go
Close
func (p *ProgressReader) Close() (err error) { err = p.r.Close() p.stopProgress() return }
go
func (p *ProgressReader) Close() (err error) { err = p.r.Close() p.stopProgress() return }
[ "func", "(", "p", "*", "ProgressReader", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "err", "=", "p", ".", "r", ".", "Close", "(", ")", "\n", "p", ".", "stopProgress", "(", ")", "\n", "return", "\n", "}" ]
// Close wraps the io.ReaderCloser Close function to clean up everything. ProgressReader // objects should always be closed to make sure everything is cleaned up.
[ "Close", "wraps", "the", "io", ".", "ReaderCloser", "Close", "function", "to", "clean", "up", "everything", ".", "ProgressReader", "objects", "should", "always", "be", "closed", "to", "make", "sure", "everything", "is", "cleaned", "up", "." ]
387f5796a6e8b84e8f9b3c1c0a97769b6b83adac
https://github.com/bartmeuris/progressio/blob/387f5796a6e8b84e8f9b3c1c0a97769b6b83adac/progressreader.go#L58-L62
149,484
octavore/nagax
util/slack/module.go
Post
func (m *Module) Post(txt string, params *PostMessageParameters) { m.PostC(m.config.SlackConfig.Channel, txt, params) }
go
func (m *Module) Post(txt string, params *PostMessageParameters) { m.PostC(m.config.SlackConfig.Channel, txt, params) }
[ "func", "(", "m", "*", "Module", ")", "Post", "(", "txt", "string", ",", "params", "*", "PostMessageParameters", ")", "{", "m", ".", "PostC", "(", "m", ".", "config", ".", "SlackConfig", ".", "Channel", ",", "txt", ",", "params", ")", "\n", "}" ]
// Post a message to the default channel
[ "Post", "a", "message", "to", "the", "default", "channel" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/util/slack/module.go#L59-L61
149,485
octavore/nagax
util/slack/module.go
PostC
func (m *Module) PostC(channel, txt string, params *PostMessageParameters) { var p PostMessageParameters if params != nil { p = *params } if m.LogMessages { m.Logger.Infof("[%s] %s", m.config.SlackConfig.Channel, txt) } _, _, err := m.client.PostMessage(channel, txt, p) if err != nil { m.Logger.Error(error...
go
func (m *Module) PostC(channel, txt string, params *PostMessageParameters) { var p PostMessageParameters if params != nil { p = *params } if m.LogMessages { m.Logger.Infof("[%s] %s", m.config.SlackConfig.Channel, txt) } _, _, err := m.client.PostMessage(channel, txt, p) if err != nil { m.Logger.Error(error...
[ "func", "(", "m", "*", "Module", ")", "PostC", "(", "channel", ",", "txt", "string", ",", "params", "*", "PostMessageParameters", ")", "{", "var", "p", "PostMessageParameters", "\n", "if", "params", "!=", "nil", "{", "p", "=", "*", "params", "\n", "}",...
// PostC posts a message to the given channel
[ "PostC", "posts", "a", "message", "to", "the", "given", "channel" ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/util/slack/module.go#L64-L76
149,486
octavore/nagax
users/oauth/module.go
Init
func (m *Module) Init(c *service.Config) { c.Start = func() { for _, p := range m.oauthConfigs { m.register(p) } } }
go
func (m *Module) Init(c *service.Config) { c.Start = func() { for _, p := range m.oauthConfigs { m.register(p) } } }
[ "func", "(", "m", "*", "Module", ")", "Init", "(", "c", "*", "service", ".", "Config", ")", "{", "c", ".", "Start", "=", "func", "(", ")", "{", "for", "_", ",", "p", ":=", "range", "m", ".", "oauthConfigs", "{", "m", ".", "register", "(", "p"...
// Init this module.
[ "Init", "this", "module", "." ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/oauth/module.go#L18-L24
149,487
octavore/nagax
users/oauth/module.go
AddProvider
func (m *Module) AddProvider(p *Provider) { m.oauthConfigs = append(m.oauthConfigs, p) }
go
func (m *Module) AddProvider(p *Provider) { m.oauthConfigs = append(m.oauthConfigs, p) }
[ "func", "(", "m", "*", "Module", ")", "AddProvider", "(", "p", "*", "Provider", ")", "{", "m", ".", "oauthConfigs", "=", "append", "(", "m", ".", "oauthConfigs", ",", "p", ")", "\n", "}" ]
// AddProvider adds a new provider to the oauth module. Provider are registered during // the Start phase.
[ "AddProvider", "adds", "a", "new", "provider", "to", "the", "oauth", "module", ".", "Provider", "are", "registered", "during", "the", "Start", "phase", "." ]
084611dbe106dfb80c5dfb9ac3e0fb071276e026
https://github.com/octavore/nagax/blob/084611dbe106dfb80c5dfb9ac3e0fb071276e026/users/oauth/module.go#L28-L30
149,488
vbatts/go-mtree
compare.go
MarshalJSON
func (i InodeDelta) MarshalJSON() ([]byte, error) { return json.Marshal(struct { Type DifferenceType `json:"type"` Path string `json:"path"` Keys []KeyDelta `json:"keys"` }{ Type: i.diff, Path: i.path, Keys: i.keys, }) }
go
func (i InodeDelta) MarshalJSON() ([]byte, error) { return json.Marshal(struct { Type DifferenceType `json:"type"` Path string `json:"path"` Keys []KeyDelta `json:"keys"` }{ Type: i.diff, Path: i.path, Keys: i.keys, }) }
[ "func", "(", "i", "InodeDelta", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "json", ".", "Marshal", "(", "struct", "{", "Type", "DifferenceType", "`json:\"type\"`", "\n", "Path", "string", "`json:\"path\"`", "\n",...
// MarshalJSON creates a JSON-encoded version of InodeDelta.
[ "MarshalJSON", "creates", "a", "JSON", "-", "encoded", "version", "of", "InodeDelta", "." ]
8b6de6073c1a0c205934283ceefc5396b96a071e
https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/compare.go#L99-L109
149,489
vbatts/go-mtree
compare.go
String
func (i InodeDelta) String() string { switch i.diff { case Modified: // Output the first failure. f := i.keys[0] return fmt.Sprintf("%q: keyword %q: expected %s; got %s", i.path, f.name, f.old, f.new) case Extra: return fmt.Sprintf("%q: unexpected path", i.path) case Missing: return fmt.Sprintf("%q: missi...
go
func (i InodeDelta) String() string { switch i.diff { case Modified: // Output the first failure. f := i.keys[0] return fmt.Sprintf("%q: keyword %q: expected %s; got %s", i.path, f.name, f.old, f.new) case Extra: return fmt.Sprintf("%q: unexpected path", i.path) case Missing: return fmt.Sprintf("%q: missi...
[ "func", "(", "i", "InodeDelta", ")", "String", "(", ")", "string", "{", "switch", "i", ".", "diff", "{", "case", "Modified", ":", "// Output the first failure.", "f", ":=", "i", ".", "keys", "[", "0", "]", "\n", "return", "fmt", ".", "Sprintf", "(", ...
// String returns a "pretty" formatting for InodeDelta.
[ "String", "returns", "a", "pretty", "formatting", "for", "InodeDelta", "." ]
8b6de6073c1a0c205934283ceefc5396b96a071e
https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/compare.go#L112-L125
149,490
vbatts/go-mtree
compare.go
MarshalJSON
func (k KeyDelta) MarshalJSON() ([]byte, error) { return json.Marshal(struct { Type DifferenceType `json:"type"` Name Keyword `json:"name"` Old string `json:"old"` New string `json:"new"` }{ Type: k.diff, Name: k.name, Old: k.old, New: k.new, }) }
go
func (k KeyDelta) MarshalJSON() ([]byte, error) { return json.Marshal(struct { Type DifferenceType `json:"type"` Name Keyword `json:"name"` Old string `json:"old"` New string `json:"new"` }{ Type: k.diff, Name: k.name, Old: k.old, New: k.new, }) }
[ "func", "(", "k", "KeyDelta", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "json", ".", "Marshal", "(", "struct", "{", "Type", "DifferenceType", "`json:\"type\"`", "\n", "Name", "Keyword", "`json:\"name\"`", "\n", ...
// MarshalJSON creates a JSON-encoded version of KeyDelta.
[ "MarshalJSON", "creates", "a", "JSON", "-", "encoded", "version", "of", "KeyDelta", "." ]
8b6de6073c1a0c205934283ceefc5396b96a071e
https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/compare.go#L173-L185
149,491
vbatts/go-mtree
compare.go
CompareSame
func CompareSame(oldDh, newDh *DirectoryHierarchy, keys []Keyword) ([]InodeDelta, error) { return compare(oldDh, newDh, keys, true) }
go
func CompareSame(oldDh, newDh *DirectoryHierarchy, keys []Keyword) ([]InodeDelta, error) { return compare(oldDh, newDh, keys, true) }
[ "func", "CompareSame", "(", "oldDh", ",", "newDh", "*", "DirectoryHierarchy", ",", "keys", "[", "]", "Keyword", ")", "(", "[", "]", "InodeDelta", ",", "error", ")", "{", "return", "compare", "(", "oldDh", ",", "newDh", ",", "keys", ",", "true", ")", ...
// CompareSame is the same as Compare, except it also includes the entries // that are the same with a Same DifferenceType.
[ "CompareSame", "is", "the", "same", "as", "Compare", "except", "it", "also", "includes", "the", "entries", "that", "are", "the", "same", "with", "a", "Same", "DifferenceType", "." ]
8b6de6073c1a0c205934283ceefc5396b96a071e
https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/compare.go#L469-L471
149,492
vbatts/go-mtree
entry.go
Descend
func (e Entry) Descend(filename string) *Entry { if filename == "." || filename == "" { return &e } numChildren := len(e.Children) for i := range e.Children { c := e.Children[numChildren-1-i] if c.Name == filename { return c } } return nil }
go
func (e Entry) Descend(filename string) *Entry { if filename == "." || filename == "" { return &e } numChildren := len(e.Children) for i := range e.Children { c := e.Children[numChildren-1-i] if c.Name == filename { return c } } return nil }
[ "func", "(", "e", "Entry", ")", "Descend", "(", "filename", "string", ")", "*", "Entry", "{", "if", "filename", "==", "\"", "\"", "||", "filename", "==", "\"", "\"", "{", "return", "&", "e", "\n", "}", "\n", "numChildren", ":=", "len", "(", "e", ...
// Descend searches thru an Entry's children to find the Entry associated with // `filename`. Directories are stored at the end of an Entry's children so do a // traverse backwards. If you descend to a "."
[ "Descend", "searches", "thru", "an", "Entry", "s", "children", "to", "find", "the", "Entry", "associated", "with", "filename", ".", "Directories", "are", "stored", "at", "the", "end", "of", "an", "Entry", "s", "children", "so", "do", "a", "traverse", "back...
8b6de6073c1a0c205934283ceefc5396b96a071e
https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/entry.go#L34-L46
149,493
vbatts/go-mtree
entry.go
Find
func (e Entry) Find(filepath string) *Entry { resultnode := &e for _, path := range strings.Split(filepath, "/") { encoded, err := govis.Vis(path, DefaultVisFlags) if err != nil { return nil } resultnode = resultnode.Descend(encoded) if resultnode == nil { return nil } } return resultnode }
go
func (e Entry) Find(filepath string) *Entry { resultnode := &e for _, path := range strings.Split(filepath, "/") { encoded, err := govis.Vis(path, DefaultVisFlags) if err != nil { return nil } resultnode = resultnode.Descend(encoded) if resultnode == nil { return nil } } return resultnode }
[ "func", "(", "e", "Entry", ")", "Find", "(", "filepath", "string", ")", "*", "Entry", "{", "resultnode", ":=", "&", "e", "\n", "for", "_", ",", "path", ":=", "range", "strings", ".", "Split", "(", "filepath", ",", "\"", "\"", ")", "{", "encoded", ...
// Find is a wrapper around Descend that takes in a whole string path and tries // to find that Entry
[ "Find", "is", "a", "wrapper", "around", "Descend", "that", "takes", "in", "a", "whole", "string", "path", "and", "tries", "to", "find", "that", "Entry" ]
8b6de6073c1a0c205934283ceefc5396b96a071e
https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/entry.go#L50-L63
149,494
vbatts/go-mtree
entry.go
Path
func (e Entry) Path() (string, error) { decodedName, err := govis.Unvis(e.Name, DefaultVisFlags) if err != nil { return "", err } decodedName = CleanPath(decodedName) if e.Parent == nil || e.Type == FullType { return decodedName, nil } parentName, err := e.Parent.Path() if err != nil { return "", err } ...
go
func (e Entry) Path() (string, error) { decodedName, err := govis.Unvis(e.Name, DefaultVisFlags) if err != nil { return "", err } decodedName = CleanPath(decodedName) if e.Parent == nil || e.Type == FullType { return decodedName, nil } parentName, err := e.Parent.Path() if err != nil { return "", err } ...
[ "func", "(", "e", "Entry", ")", "Path", "(", ")", "(", "string", ",", "error", ")", "{", "decodedName", ",", "err", ":=", "govis", ".", "Unvis", "(", "e", ".", "Name", ",", "DefaultVisFlags", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\...
// Path provides the full path of the file, despite RelativeType or FullType. It // will be in Unvis'd form.
[ "Path", "provides", "the", "full", "path", "of", "the", "file", "despite", "RelativeType", "or", "FullType", ".", "It", "will", "be", "in", "Unvis", "d", "form", "." ]
8b6de6073c1a0c205934283ceefc5396b96a071e
https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/entry.go#L106-L120
149,495
vbatts/go-mtree
entry.go
String
func (e Entry) String() string { if e.Raw != "" { return e.Raw } if e.Type == BlankType { return "" } if e.Type == DotDotType { return e.Name } if e.Type == SpecialType || e.Type == FullType || inKeyValSlice("type=dir", e.Keywords) { return fmt.Sprintf("%s %s", e.Name, strings.Join(KeyValToString(e.Keywo...
go
func (e Entry) String() string { if e.Raw != "" { return e.Raw } if e.Type == BlankType { return "" } if e.Type == DotDotType { return e.Name } if e.Type == SpecialType || e.Type == FullType || inKeyValSlice("type=dir", e.Keywords) { return fmt.Sprintf("%s %s", e.Name, strings.Join(KeyValToString(e.Keywo...
[ "func", "(", "e", "Entry", ")", "String", "(", ")", "string", "{", "if", "e", ".", "Raw", "!=", "\"", "\"", "{", "return", "e", ".", "Raw", "\n", "}", "\n", "if", "e", ".", "Type", "==", "BlankType", "{", "return", "\"", "\"", "\n", "}", "\n"...
// String joins a file with its associated keywords. The file name will be the // Vis'd encoded version so that it can be parsed appropriately when Check'd.
[ "String", "joins", "a", "file", "with", "its", "associated", "keywords", ".", "The", "file", "name", "will", "be", "the", "Vis", "d", "encoded", "version", "so", "that", "it", "can", "be", "parsed", "appropriately", "when", "Check", "d", "." ]
8b6de6073c1a0c205934283ceefc5396b96a071e
https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/entry.go#L124-L138
149,496
vbatts/go-mtree
entry.go
IsDir
func (e Entry) IsDir() bool { for _, kv := range e.AllKeys() { if kv.Keyword().Prefix() == "type" { return kv.Value() == "dir" } } return false }
go
func (e Entry) IsDir() bool { for _, kv := range e.AllKeys() { if kv.Keyword().Prefix() == "type" { return kv.Value() == "dir" } } return false }
[ "func", "(", "e", "Entry", ")", "IsDir", "(", ")", "bool", "{", "for", "_", ",", "kv", ":=", "range", "e", ".", "AllKeys", "(", ")", "{", "if", "kv", ".", "Keyword", "(", ")", ".", "Prefix", "(", ")", "==", "\"", "\"", "{", "return", "kv", ...
// IsDir checks the type= value for this entry on whether it is a directory
[ "IsDir", "checks", "the", "type", "=", "value", "for", "this", "entry", "on", "whether", "it", "is", "a", "directory" ]
8b6de6073c1a0c205934283ceefc5396b96a071e
https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/entry.go#L151-L158
149,497
vbatts/go-mtree
cksum.go
cksum
func cksum(r io.Reader) (uint32, int, error) { in := bufio.NewReader(r) count := 0 var sum uint32 f := func(b byte) { for i := 7; i >= 0; i-- { msb := sum & (1 << 31) sum = sum << 1 if msb != 0 { sum = sum ^ posixPolynomial } } sum ^= uint32(b) } for done := false; !done; { switch b, err ...
go
func cksum(r io.Reader) (uint32, int, error) { in := bufio.NewReader(r) count := 0 var sum uint32 f := func(b byte) { for i := 7; i >= 0; i-- { msb := sum & (1 << 31) sum = sum << 1 if msb != 0 { sum = sum ^ posixPolynomial } } sum ^= uint32(b) } for done := false; !done; { switch b, err ...
[ "func", "cksum", "(", "r", "io", ".", "Reader", ")", "(", "uint32", ",", "int", ",", "error", ")", "{", "in", ":=", "bufio", ".", "NewReader", "(", "r", ")", "\n", "count", ":=", "0", "\n", "var", "sum", "uint32", "\n", "f", ":=", "func", "(", ...
// cksum is an implementation of the POSIX CRC algorithm
[ "cksum", "is", "an", "implementation", "of", "the", "POSIX", "CRC", "algorithm" ]
8b6de6073c1a0c205934283ceefc5396b96a071e
https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/cksum.go#L11-L49
149,498
vbatts/go-mtree
walk.go
startWalk
func startWalk(c *dhCreator, root string, walkFn filepath.WalkFunc) error { info, err := c.fs.Lstat(root) if err != nil { return walkFn(root, nil, err) } return walk(c, root, info, walkFn) }
go
func startWalk(c *dhCreator, root string, walkFn filepath.WalkFunc) error { info, err := c.fs.Lstat(root) if err != nil { return walkFn(root, nil, err) } return walk(c, root, info, walkFn) }
[ "func", "startWalk", "(", "c", "*", "dhCreator", ",", "root", "string", ",", "walkFn", "filepath", ".", "WalkFunc", ")", "error", "{", "info", ",", "err", ":=", "c", ".", "fs", ".", "Lstat", "(", "root", ")", "\n", "if", "err", "!=", "nil", "{", ...
// startWalk walks the file tree rooted at root, calling walkFn for each file or // directory in the tree, including root. All errors that arise visiting files // and directories are filtered by walkFn. The files are walked in lexical // order, which makes the output deterministic but means that for very // large direc...
[ "startWalk", "walks", "the", "file", "tree", "rooted", "at", "root", "calling", "walkFn", "for", "each", "file", "or", "directory", "in", "the", "tree", "including", "root", ".", "All", "errors", "that", "arise", "visiting", "files", "and", "directories", "a...
8b6de6073c1a0c205934283ceefc5396b96a071e
https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/walk.go#L243-L249
149,499
vbatts/go-mtree
walk.go
readOrderedDirNames
func readOrderedDirNames(c *dhCreator, dirname string) ([]string, error) { infos, err := c.fs.Readdir(dirname) if err != nil { return nil, err } names := []string{} dirnames := []string{} for _, info := range infos { if info.IsDir() { dirnames = append(dirnames, info.Name()) continue } names = appe...
go
func readOrderedDirNames(c *dhCreator, dirname string) ([]string, error) { infos, err := c.fs.Readdir(dirname) if err != nil { return nil, err } names := []string{} dirnames := []string{} for _, info := range infos { if info.IsDir() { dirnames = append(dirnames, info.Name()) continue } names = appe...
[ "func", "readOrderedDirNames", "(", "c", "*", "dhCreator", ",", "dirname", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "infos", ",", "err", ":=", "c", ".", "fs", ".", "Readdir", "(", "dirname", ")", "\n", "if", "err", "!=", "nil...
// readOrderedDirNames reads the directory and returns a sorted list of all // entries with non-directories first, followed by directories.
[ "readOrderedDirNames", "reads", "the", "directory", "and", "returns", "a", "sorted", "list", "of", "all", "entries", "with", "non", "-", "directories", "first", "followed", "by", "directories", "." ]
8b6de6073c1a0c205934283ceefc5396b96a071e
https://github.com/vbatts/go-mtree/blob/8b6de6073c1a0c205934283ceefc5396b96a071e/walk.go#L299-L317