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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
127,500 | ipfs/go-ipfs | provider/queue.go | NewQueue | func NewQueue(ctx context.Context, name string, ds datastore.Datastore) (*Queue, error) {
namespaced := namespace.Wrap(ds, datastore.NewKey("/"+name+"/queue/"))
head, tail, err := getQueueHeadTail(ctx, namespaced)
if err != nil {
return nil, err
}
cancelCtx, cancel := context.WithCancel(ctx)
q := &Queue{
name... | go | func NewQueue(ctx context.Context, name string, ds datastore.Datastore) (*Queue, error) {
namespaced := namespace.Wrap(ds, datastore.NewKey("/"+name+"/queue/"))
head, tail, err := getQueueHeadTail(ctx, namespaced)
if err != nil {
return nil, err
}
cancelCtx, cancel := context.WithCancel(ctx)
q := &Queue{
name... | [
"func",
"NewQueue",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"ds",
"datastore",
".",
"Datastore",
")",
"(",
"*",
"Queue",
",",
"error",
")",
"{",
"namespaced",
":=",
"namespace",
".",
"Wrap",
"(",
"ds",
",",
"datastore",
".",
... | // NewQueue creates a queue for cids | [
"NewQueue",
"creates",
"a",
"queue",
"for",
"cids"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/provider/queue.go#L35-L55 |
127,501 | ipfs/go-ipfs | provider/queue.go | Enqueue | func (q *Queue) Enqueue(cid cid.Cid) {
select {
case q.enqueue <- cid:
case <-q.ctx.Done():
}
} | go | func (q *Queue) Enqueue(cid cid.Cid) {
select {
case q.enqueue <- cid:
case <-q.ctx.Done():
}
} | [
"func",
"(",
"q",
"*",
"Queue",
")",
"Enqueue",
"(",
"cid",
"cid",
".",
"Cid",
")",
"{",
"select",
"{",
"case",
"q",
".",
"enqueue",
"<-",
"cid",
":",
"case",
"<-",
"q",
".",
"ctx",
".",
"Done",
"(",
")",
":",
"}",
"\n",
"}"
] | // Enqueue puts a cid in the queue | [
"Enqueue",
"puts",
"a",
"cid",
"in",
"the",
"queue"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/provider/queue.go#L65-L70 |
127,502 | ipfs/go-ipfs | keystore/keystore.go | Has | func (ks *FSKeystore) Has(name string) (bool, error) {
kp := filepath.Join(ks.dir, name)
_, err := os.Stat(kp)
if os.IsNotExist(err) {
return false, nil
}
if err != nil {
return false, err
}
if err := validateName(name); err != nil {
return false, err
}
return true, nil
} | go | func (ks *FSKeystore) Has(name string) (bool, error) {
kp := filepath.Join(ks.dir, name)
_, err := os.Stat(kp)
if os.IsNotExist(err) {
return false, nil
}
if err != nil {
return false, err
}
if err := validateName(name); err != nil {
return false, err
}
return true, nil
} | [
"func",
"(",
"ks",
"*",
"FSKeystore",
")",
"Has",
"(",
"name",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"kp",
":=",
"filepath",
".",
"Join",
"(",
"ks",
".",
"dir",
",",
"name",
")",
"\n\n",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
... | // Has returns whether or not a key exist in the Keystore | [
"Has",
"returns",
"whether",
"or",
"not",
"a",
"key",
"exist",
"in",
"the",
"Keystore"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/keystore/keystore.go#L70-L88 |
127,503 | ipfs/go-ipfs | keystore/keystore.go | Put | func (ks *FSKeystore) Put(name string, k ci.PrivKey) error {
if err := validateName(name); err != nil {
return err
}
b, err := k.Bytes()
if err != nil {
return err
}
kp := filepath.Join(ks.dir, name)
_, err = os.Stat(kp)
if err == nil {
return ErrKeyExists
} else if !os.IsNotExist(err) {
return err
... | go | func (ks *FSKeystore) Put(name string, k ci.PrivKey) error {
if err := validateName(name); err != nil {
return err
}
b, err := k.Bytes()
if err != nil {
return err
}
kp := filepath.Join(ks.dir, name)
_, err = os.Stat(kp)
if err == nil {
return ErrKeyExists
} else if !os.IsNotExist(err) {
return err
... | [
"func",
"(",
"ks",
"*",
"FSKeystore",
")",
"Put",
"(",
"name",
"string",
",",
"k",
"ci",
".",
"PrivKey",
")",
"error",
"{",
"if",
"err",
":=",
"validateName",
"(",
"name",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"b"... | // Put stores a key in the Keystore, if a key with the same name already exists, returns ErrKeyExists | [
"Put",
"stores",
"a",
"key",
"in",
"the",
"Keystore",
"if",
"a",
"key",
"with",
"the",
"same",
"name",
"already",
"exists",
"returns",
"ErrKeyExists"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/keystore/keystore.go#L91-L119 |
127,504 | ipfs/go-ipfs | keystore/keystore.go | Get | func (ks *FSKeystore) Get(name string) (ci.PrivKey, error) {
if err := validateName(name); err != nil {
return nil, err
}
kp := filepath.Join(ks.dir, name)
data, err := ioutil.ReadFile(kp)
if err != nil {
if os.IsNotExist(err) {
return nil, ErrNoSuchKey
}
return nil, err
}
return ci.UnmarshalPrivat... | go | func (ks *FSKeystore) Get(name string) (ci.PrivKey, error) {
if err := validateName(name); err != nil {
return nil, err
}
kp := filepath.Join(ks.dir, name)
data, err := ioutil.ReadFile(kp)
if err != nil {
if os.IsNotExist(err) {
return nil, ErrNoSuchKey
}
return nil, err
}
return ci.UnmarshalPrivat... | [
"func",
"(",
"ks",
"*",
"FSKeystore",
")",
"Get",
"(",
"name",
"string",
")",
"(",
"ci",
".",
"PrivKey",
",",
"error",
")",
"{",
"if",
"err",
":=",
"validateName",
"(",
"name",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",... | // Get retrieves a key from the Keystore if it exists, and returns ErrNoSuchKey
// otherwise. | [
"Get",
"retrieves",
"a",
"key",
"from",
"the",
"Keystore",
"if",
"it",
"exists",
"and",
"returns",
"ErrNoSuchKey",
"otherwise",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/keystore/keystore.go#L123-L139 |
127,505 | ipfs/go-ipfs | keystore/keystore.go | Delete | func (ks *FSKeystore) Delete(name string) error {
if err := validateName(name); err != nil {
return err
}
kp := filepath.Join(ks.dir, name)
return os.Remove(kp)
} | go | func (ks *FSKeystore) Delete(name string) error {
if err := validateName(name); err != nil {
return err
}
kp := filepath.Join(ks.dir, name)
return os.Remove(kp)
} | [
"func",
"(",
"ks",
"*",
"FSKeystore",
")",
"Delete",
"(",
"name",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"validateName",
"(",
"name",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"kp",
":=",
"filepath",
".",
"Join... | // Delete removes a key from the Keystore | [
"Delete",
"removes",
"a",
"key",
"from",
"the",
"Keystore"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/keystore/keystore.go#L142-L150 |
127,506 | ipfs/go-ipfs | namesys/publisher.go | NewIpnsPublisher | func NewIpnsPublisher(route routing.ValueStore, ds ds.Datastore) *IpnsPublisher {
if ds == nil {
panic("nil datastore")
}
return &IpnsPublisher{routing: route, ds: ds}
} | go | func NewIpnsPublisher(route routing.ValueStore, ds ds.Datastore) *IpnsPublisher {
if ds == nil {
panic("nil datastore")
}
return &IpnsPublisher{routing: route, ds: ds}
} | [
"func",
"NewIpnsPublisher",
"(",
"route",
"routing",
".",
"ValueStore",
",",
"ds",
"ds",
".",
"Datastore",
")",
"*",
"IpnsPublisher",
"{",
"if",
"ds",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"&",
"IpnsPublisher",
"{"... | // NewIpnsPublisher constructs a publisher for the IPFS Routing name system. | [
"NewIpnsPublisher",
"constructs",
"a",
"publisher",
"for",
"the",
"IPFS",
"Routing",
"name",
"system",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/namesys/publisher.go#L40-L45 |
127,507 | ipfs/go-ipfs | namesys/publisher.go | Publish | func (p *IpnsPublisher) Publish(ctx context.Context, k ci.PrivKey, value path.Path) error {
log.Debugf("Publish %s", value)
return p.PublishWithEOL(ctx, k, value, time.Now().Add(DefaultRecordEOL))
} | go | func (p *IpnsPublisher) Publish(ctx context.Context, k ci.PrivKey, value path.Path) error {
log.Debugf("Publish %s", value)
return p.PublishWithEOL(ctx, k, value, time.Now().Add(DefaultRecordEOL))
} | [
"func",
"(",
"p",
"*",
"IpnsPublisher",
")",
"Publish",
"(",
"ctx",
"context",
".",
"Context",
",",
"k",
"ci",
".",
"PrivKey",
",",
"value",
"path",
".",
"Path",
")",
"error",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"value",
")",
"\n",
"... | // Publish implements Publisher. Accepts a keypair and a value,
// and publishes it out to the routing system | [
"Publish",
"implements",
"Publisher",
".",
"Accepts",
"a",
"keypair",
"and",
"a",
"value",
"and",
"publishes",
"it",
"out",
"to",
"the",
"routing",
"system"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/namesys/publisher.go#L49-L52 |
127,508 | ipfs/go-ipfs | namesys/publisher.go | ListPublished | func (p *IpnsPublisher) ListPublished(ctx context.Context) (map[peer.ID]*pb.IpnsEntry, error) {
query, err := p.ds.Query(dsquery.Query{
Prefix: ipnsPrefix,
})
if err != nil {
return nil, err
}
defer query.Close()
records := make(map[peer.ID]*pb.IpnsEntry)
for {
select {
case result, ok := <-query.Next()... | go | func (p *IpnsPublisher) ListPublished(ctx context.Context) (map[peer.ID]*pb.IpnsEntry, error) {
query, err := p.ds.Query(dsquery.Query{
Prefix: ipnsPrefix,
})
if err != nil {
return nil, err
}
defer query.Close()
records := make(map[peer.ID]*pb.IpnsEntry)
for {
select {
case result, ok := <-query.Next()... | [
"func",
"(",
"p",
"*",
"IpnsPublisher",
")",
"ListPublished",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"map",
"[",
"peer",
".",
"ID",
"]",
"*",
"pb",
".",
"IpnsEntry",
",",
"error",
")",
"{",
"query",
",",
"err",
":=",
"p",
".",
"ds",
"."... | // PublishedNames returns the latest IPNS records published by this node and
// their expiration times.
//
// This method will not search the routing system for records published by other
// nodes. | [
"PublishedNames",
"returns",
"the",
"latest",
"IPNS",
"records",
"published",
"by",
"this",
"node",
"and",
"their",
"expiration",
"times",
".",
"This",
"method",
"will",
"not",
"search",
"the",
"routing",
"system",
"for",
"records",
"published",
"by",
"other",
... | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/namesys/publisher.go#L63-L103 |
127,509 | ipfs/go-ipfs | namesys/publisher.go | GetPublished | func (p *IpnsPublisher) GetPublished(ctx context.Context, id peer.ID, checkRouting bool) (*pb.IpnsEntry, error) {
ctx, cancel := context.WithTimeout(ctx, time.Second*30)
defer cancel()
value, err := p.ds.Get(IpnsDsKey(id))
switch err {
case nil:
case ds.ErrNotFound:
if !checkRouting {
return nil, nil
}
... | go | func (p *IpnsPublisher) GetPublished(ctx context.Context, id peer.ID, checkRouting bool) (*pb.IpnsEntry, error) {
ctx, cancel := context.WithTimeout(ctx, time.Second*30)
defer cancel()
value, err := p.ds.Get(IpnsDsKey(id))
switch err {
case nil:
case ds.ErrNotFound:
if !checkRouting {
return nil, nil
}
... | [
"func",
"(",
"p",
"*",
"IpnsPublisher",
")",
"GetPublished",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"peer",
".",
"ID",
",",
"checkRouting",
"bool",
")",
"(",
"*",
"pb",
".",
"IpnsEntry",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
... | // GetPublished returns the record this node has published corresponding to the
// given peer ID.
//
// If `checkRouting` is true and we have no existing record, this method will
// check the routing system for any existing records. | [
"GetPublished",
"returns",
"the",
"record",
"this",
"node",
"has",
"published",
"corresponding",
"to",
"the",
"given",
"peer",
"ID",
".",
"If",
"checkRouting",
"is",
"true",
"and",
"we",
"have",
"no",
"existing",
"record",
"this",
"method",
"will",
"check",
... | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/namesys/publisher.go#L110-L140 |
127,510 | ipfs/go-ipfs | namesys/publisher.go | checkCtxTTL | func checkCtxTTL(ctx context.Context) (time.Duration, bool) {
v := ctx.Value("ipns-publish-ttl")
if v == nil {
return 0, false
}
d, ok := v.(time.Duration)
return d, ok
} | go | func checkCtxTTL(ctx context.Context) (time.Duration, bool) {
v := ctx.Value("ipns-publish-ttl")
if v == nil {
return 0, false
}
d, ok := v.(time.Duration)
return d, ok
} | [
"func",
"checkCtxTTL",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"time",
".",
"Duration",
",",
"bool",
")",
"{",
"v",
":=",
"ctx",
".",
"Value",
"(",
"\"",
"\"",
")",
"\n",
"if",
"v",
"==",
"nil",
"{",
"return",
"0",
",",
"false",
"\n",
... | // setting the TTL on published records is an experimental feature.
// as such, i'm using the context to wire it through to avoid changing too
// much code along the way. | [
"setting",
"the",
"TTL",
"on",
"published",
"records",
"is",
"an",
"experimental",
"feature",
".",
"as",
"such",
"i",
"m",
"using",
"the",
"context",
"to",
"wire",
"it",
"through",
"to",
"avoid",
"changing",
"too",
"much",
"code",
"along",
"the",
"way",
... | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/namesys/publisher.go#L203-L211 |
127,511 | ipfs/go-ipfs | namesys/republisher/repub.go | NewRepublisher | func NewRepublisher(ns namesys.Publisher, ds ds.Datastore, self ic.PrivKey, ks keystore.Keystore) *Republisher {
return &Republisher{
ns: ns,
ds: ds,
self: self,
ks: ks,
Interval: DefaultRebroadcastInterval,
RecordLifetime: DefaultRecordLifetime,
}
} | go | func NewRepublisher(ns namesys.Publisher, ds ds.Datastore, self ic.PrivKey, ks keystore.Keystore) *Republisher {
return &Republisher{
ns: ns,
ds: ds,
self: self,
ks: ks,
Interval: DefaultRebroadcastInterval,
RecordLifetime: DefaultRecordLifetime,
}
} | [
"func",
"NewRepublisher",
"(",
"ns",
"namesys",
".",
"Publisher",
",",
"ds",
"ds",
".",
"Datastore",
",",
"self",
"ic",
".",
"PrivKey",
",",
"ks",
"keystore",
".",
"Keystore",
")",
"*",
"Republisher",
"{",
"return",
"&",
"Republisher",
"{",
"ns",
":",
... | // NewRepublisher creates a new Republisher | [
"NewRepublisher",
"creates",
"a",
"new",
"Republisher"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/namesys/republisher/repub.go#L51-L60 |
127,512 | ipfs/go-ipfs | core/commands/swarm.go | directionString | func directionString(d inet.Direction) string {
switch d {
case inet.DirInbound:
return "inbound"
case inet.DirOutbound:
return "outbound"
default:
return ""
}
} | go | func directionString(d inet.Direction) string {
switch d {
case inet.DirInbound:
return "inbound"
case inet.DirOutbound:
return "outbound"
default:
return ""
}
} | [
"func",
"directionString",
"(",
"d",
"inet",
".",
"Direction",
")",
"string",
"{",
"switch",
"d",
"{",
"case",
"inet",
".",
"DirInbound",
":",
"return",
"\"",
"\"",
"\n",
"case",
"inet",
".",
"DirOutbound",
":",
"return",
"\"",
"\"",
"\n",
"default",
"... | // directionString transfers to string | [
"directionString",
"transfers",
"to",
"string"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/swarm.go#L209-L218 |
127,513 | ipfs/go-ipfs | core/commands/swarm.go | parseMultiaddrs | func parseMultiaddrs(maddrs []ma.Multiaddr) (iaddrs []iaddr.IPFSAddr, err error) {
iaddrs = make([]iaddr.IPFSAddr, len(maddrs))
for i, maddr := range maddrs {
iaddrs[i], err = iaddr.ParseMultiaddr(maddr)
if err != nil {
return nil, cmds.ClientError("invalid peer address: " + err.Error())
}
}
return
} | go | func parseMultiaddrs(maddrs []ma.Multiaddr) (iaddrs []iaddr.IPFSAddr, err error) {
iaddrs = make([]iaddr.IPFSAddr, len(maddrs))
for i, maddr := range maddrs {
iaddrs[i], err = iaddr.ParseMultiaddr(maddr)
if err != nil {
return nil, cmds.ClientError("invalid peer address: " + err.Error())
}
}
return
} | [
"func",
"parseMultiaddrs",
"(",
"maddrs",
"[",
"]",
"ma",
".",
"Multiaddr",
")",
"(",
"iaddrs",
"[",
"]",
"iaddr",
".",
"IPFSAddr",
",",
"err",
"error",
")",
"{",
"iaddrs",
"=",
"make",
"(",
"[",
"]",
"iaddr",
".",
"IPFSAddr",
",",
"len",
"(",
"mad... | // parseMultiaddrs is a function that takes in a slice of peer multiaddr
// and returns slices of multiaddrs and peerids | [
"parseMultiaddrs",
"is",
"a",
"function",
"that",
"takes",
"in",
"a",
"slice",
"of",
"peer",
"multiaddr",
"and",
"returns",
"slices",
"of",
"multiaddrs",
"and",
"peerids"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/swarm.go#L457-L466 |
127,514 | ipfs/go-ipfs | core/commands/swarm.go | resolveAddresses | func resolveAddresses(ctx context.Context, addrs []string) ([]ma.Multiaddr, error) {
ctx, cancel := context.WithTimeout(ctx, dnsResolveTimeout)
defer cancel()
var maddrs []ma.Multiaddr
var wg sync.WaitGroup
resolveErrC := make(chan error, len(addrs))
maddrC := make(chan ma.Multiaddr)
for _, addr := range addr... | go | func resolveAddresses(ctx context.Context, addrs []string) ([]ma.Multiaddr, error) {
ctx, cancel := context.WithTimeout(ctx, dnsResolveTimeout)
defer cancel()
var maddrs []ma.Multiaddr
var wg sync.WaitGroup
resolveErrC := make(chan error, len(addrs))
maddrC := make(chan ma.Multiaddr)
for _, addr := range addr... | [
"func",
"resolveAddresses",
"(",
"ctx",
"context",
".",
"Context",
",",
"addrs",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"ma",
".",
"Multiaddr",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"ctx",
",",
"dnsR... | // resolveAddresses resolves addresses parallelly | [
"resolveAddresses",
"resolves",
"addresses",
"parallelly"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/swarm.go#L503-L561 |
127,515 | ipfs/go-ipfs | core/coreapi/key.go | Generate | func (api *KeyAPI) Generate(ctx context.Context, name string, opts ...caopts.KeyGenerateOption) (coreiface.Key, error) {
options, err := caopts.KeyGenerateOptions(opts...)
if err != nil {
return nil, err
}
if name == "self" {
return nil, fmt.Errorf("cannot create key with name 'self'")
}
_, err = api.repo.K... | go | func (api *KeyAPI) Generate(ctx context.Context, name string, opts ...caopts.KeyGenerateOption) (coreiface.Key, error) {
options, err := caopts.KeyGenerateOptions(opts...)
if err != nil {
return nil, err
}
if name == "self" {
return nil, fmt.Errorf("cannot create key with name 'self'")
}
_, err = api.repo.K... | [
"func",
"(",
"api",
"*",
"KeyAPI",
")",
"Generate",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"opts",
"...",
"caopts",
".",
"KeyGenerateOption",
")",
"(",
"coreiface",
".",
"Key",
",",
"error",
")",
"{",
"options",
",",
"err",
... | // Generate generates new key, stores it in the keystore under the specified
// name and returns a base58 encoded multihash of its public key. | [
"Generate",
"generates",
"new",
"key",
"stores",
"it",
"in",
"the",
"keystore",
"under",
"the",
"specified",
"name",
"and",
"returns",
"a",
"base58",
"encoded",
"multihash",
"of",
"its",
"public",
"key",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coreapi/key.go#L42-L96 |
127,516 | ipfs/go-ipfs | core/coreapi/key.go | List | func (api *KeyAPI) List(ctx context.Context) ([]coreiface.Key, error) {
keys, err := api.repo.Keystore().List()
if err != nil {
return nil, err
}
sort.Strings(keys)
out := make([]coreiface.Key, len(keys)+1)
out[0] = &key{"self", api.identity}
for n, k := range keys {
privKey, err := api.repo.Keystore().Ge... | go | func (api *KeyAPI) List(ctx context.Context) ([]coreiface.Key, error) {
keys, err := api.repo.Keystore().List()
if err != nil {
return nil, err
}
sort.Strings(keys)
out := make([]coreiface.Key, len(keys)+1)
out[0] = &key{"self", api.identity}
for n, k := range keys {
privKey, err := api.repo.Keystore().Ge... | [
"func",
"(",
"api",
"*",
"KeyAPI",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"coreiface",
".",
"Key",
",",
"error",
")",
"{",
"keys",
",",
"err",
":=",
"api",
".",
"repo",
".",
"Keystore",
"(",
")",
".",
"List",
"(... | // List returns a list keys stored in keystore. | [
"List",
"returns",
"a",
"list",
"keys",
"stored",
"in",
"keystore",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coreapi/key.go#L99-L126 |
127,517 | ipfs/go-ipfs | core/coreapi/key.go | Rename | func (api *KeyAPI) Rename(ctx context.Context, oldName string, newName string, opts ...caopts.KeyRenameOption) (coreiface.Key, bool, error) {
options, err := caopts.KeyRenameOptions(opts...)
if err != nil {
return nil, false, err
}
ks := api.repo.Keystore()
if oldName == "self" {
return nil, false, fmt.Error... | go | func (api *KeyAPI) Rename(ctx context.Context, oldName string, newName string, opts ...caopts.KeyRenameOption) (coreiface.Key, bool, error) {
options, err := caopts.KeyRenameOptions(opts...)
if err != nil {
return nil, false, err
}
ks := api.repo.Keystore()
if oldName == "self" {
return nil, false, fmt.Error... | [
"func",
"(",
"api",
"*",
"KeyAPI",
")",
"Rename",
"(",
"ctx",
"context",
".",
"Context",
",",
"oldName",
"string",
",",
"newName",
"string",
",",
"opts",
"...",
"caopts",
".",
"KeyRenameOption",
")",
"(",
"coreiface",
".",
"Key",
",",
"bool",
",",
"err... | // Rename renames `oldName` to `newName`. Returns the key and whether another
// key was overwritten, or an error. | [
"Rename",
"renames",
"oldName",
"to",
"newName",
".",
"Returns",
"the",
"key",
"and",
"whether",
"another",
"key",
"was",
"overwritten",
"or",
"an",
"error",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coreapi/key.go#L130-L186 |
127,518 | ipfs/go-ipfs | core/coreapi/key.go | Remove | func (api *KeyAPI) Remove(ctx context.Context, name string) (coreiface.Key, error) {
ks := api.repo.Keystore()
if name == "self" {
return nil, fmt.Errorf("cannot remove key with name 'self'")
}
removed, err := ks.Get(name)
if err != nil {
return nil, fmt.Errorf("no key named %s was found", name)
}
pubKey ... | go | func (api *KeyAPI) Remove(ctx context.Context, name string) (coreiface.Key, error) {
ks := api.repo.Keystore()
if name == "self" {
return nil, fmt.Errorf("cannot remove key with name 'self'")
}
removed, err := ks.Get(name)
if err != nil {
return nil, fmt.Errorf("no key named %s was found", name)
}
pubKey ... | [
"func",
"(",
"api",
"*",
"KeyAPI",
")",
"Remove",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"coreiface",
".",
"Key",
",",
"error",
")",
"{",
"ks",
":=",
"api",
".",
"repo",
".",
"Keystore",
"(",
")",
"\n\n",
"if",
"n... | // Remove removes keys from keystore. Returns ipns path of the removed key. | [
"Remove",
"removes",
"keys",
"from",
"keystore",
".",
"Returns",
"ipns",
"path",
"of",
"the",
"removed",
"key",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coreapi/key.go#L189-L214 |
127,519 | ipfs/go-ipfs | core/core.go | Context | func (n *IpfsNode) Context() context.Context {
if n.ctx == nil {
n.ctx = context.TODO()
}
return n.ctx
} | go | func (n *IpfsNode) Context() context.Context {
if n.ctx == nil {
n.ctx = context.TODO()
}
return n.ctx
} | [
"func",
"(",
"n",
"*",
"IpfsNode",
")",
"Context",
"(",
")",
"context",
".",
"Context",
"{",
"if",
"n",
".",
"ctx",
"==",
"nil",
"{",
"n",
".",
"ctx",
"=",
"context",
".",
"TODO",
"(",
")",
"\n",
"}",
"\n",
"return",
"n",
".",
"ctx",
"\n",
"}... | // Context returns the IpfsNode context | [
"Context",
"returns",
"the",
"IpfsNode",
"context"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/core.go#L131-L136 |
127,520 | ipfs/go-ipfs | thirdparty/dir/dir.go | Writable | func Writable(path string) error {
// Construct the path if missing
if err := os.MkdirAll(path, os.ModePerm); err != nil {
return err
}
// Check the directory is writable
if f, err := os.Create(filepath.Join(path, "._check_writable")); err == nil {
f.Close()
os.Remove(f.Name())
} else {
return errors.New(... | go | func Writable(path string) error {
// Construct the path if missing
if err := os.MkdirAll(path, os.ModePerm); err != nil {
return err
}
// Check the directory is writable
if f, err := os.Create(filepath.Join(path, "._check_writable")); err == nil {
f.Close()
os.Remove(f.Name())
} else {
return errors.New(... | [
"func",
"Writable",
"(",
"path",
"string",
")",
"error",
"{",
"// Construct the path if missing",
"if",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"path",
",",
"os",
".",
"ModePerm",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"/... | // Writable ensures the directory exists and is writable | [
"Writable",
"ensures",
"the",
"directory",
"exists",
"and",
"is",
"writable"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/thirdparty/dir/dir.go#L12-L25 |
127,521 | ipfs/go-ipfs | cmd/ipfs/main.go | commandDetails | func commandDetails(path []string) *cmdDetails {
var details cmdDetails
// find the last command in path that has a cmdDetailsMap entry
for i := range path {
if cmdDetails, found := cmdDetailsMap[strings.Join(path[:i+1], "/")]; found {
details = cmdDetails
}
}
return &details
} | go | func commandDetails(path []string) *cmdDetails {
var details cmdDetails
// find the last command in path that has a cmdDetailsMap entry
for i := range path {
if cmdDetails, found := cmdDetailsMap[strings.Join(path[:i+1], "/")]; found {
details = cmdDetails
}
}
return &details
} | [
"func",
"commandDetails",
"(",
"path",
"[",
"]",
"string",
")",
"*",
"cmdDetails",
"{",
"var",
"details",
"cmdDetails",
"\n",
"// find the last command in path that has a cmdDetailsMap entry",
"for",
"i",
":=",
"range",
"path",
"{",
"if",
"cmdDetails",
",",
"found",... | // commandDetails returns a command's details for the command given by |path|. | [
"commandDetails",
"returns",
"a",
"command",
"s",
"details",
"for",
"the",
"command",
"given",
"by",
"|path|",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/cmd/ipfs/main.go#L230-L239 |
127,522 | ipfs/go-ipfs | cmd/ipfs/main.go | commandShouldRunOnDaemon | func commandShouldRunOnDaemon(details cmdDetails, req *cmds.Request, cctx *oldcmds.Context) (http.Client, error) {
path := req.Path
// root command.
if len(path) < 1 {
return nil, nil
}
if details.cannotRunOnClient && details.cannotRunOnDaemon {
return nil, fmt.Errorf("command disabled: %s", path[0])
}
if ... | go | func commandShouldRunOnDaemon(details cmdDetails, req *cmds.Request, cctx *oldcmds.Context) (http.Client, error) {
path := req.Path
// root command.
if len(path) < 1 {
return nil, nil
}
if details.cannotRunOnClient && details.cannotRunOnDaemon {
return nil, fmt.Errorf("command disabled: %s", path[0])
}
if ... | [
"func",
"commandShouldRunOnDaemon",
"(",
"details",
"cmdDetails",
",",
"req",
"*",
"cmds",
".",
"Request",
",",
"cctx",
"*",
"oldcmds",
".",
"Context",
")",
"(",
"http",
".",
"Client",
",",
"error",
")",
"{",
"path",
":=",
"req",
".",
"Path",
"\n",
"//... | // commandShouldRunOnDaemon determines, from command details, whether a
// command ought to be executed on an ipfs daemon.
//
// It returns a client if the command should be executed on a daemon and nil if
// it should be executed on a client. It returns an error if the command must
// NOT be executed on either. | [
"commandShouldRunOnDaemon",
"determines",
"from",
"command",
"details",
"whether",
"a",
"command",
"ought",
"to",
"be",
"executed",
"on",
"an",
"ipfs",
"daemon",
".",
"It",
"returns",
"a",
"client",
"if",
"the",
"command",
"should",
"be",
"executed",
"on",
"a"... | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/cmd/ipfs/main.go#L247-L299 |
127,523 | ipfs/go-ipfs | cmd/ipfs/main.go | startProfiling | func startProfiling() (func(), error) {
// start CPU profiling as early as possible
ofi, err := os.Create(cpuProfile)
if err != nil {
return nil, err
}
err = pprof.StartCPUProfile(ofi)
if err != nil {
ofi.Close()
return nil, err
}
go func() {
for range time.NewTicker(time.Second * 30).C {
err := writ... | go | func startProfiling() (func(), error) {
// start CPU profiling as early as possible
ofi, err := os.Create(cpuProfile)
if err != nil {
return nil, err
}
err = pprof.StartCPUProfile(ofi)
if err != nil {
ofi.Close()
return nil, err
}
go func() {
for range time.NewTicker(time.Second * 30).C {
err := writ... | [
"func",
"startProfiling",
"(",
")",
"(",
"func",
"(",
")",
",",
"error",
")",
"{",
"// start CPU profiling as early as possible",
"ofi",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"cpuProfile",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
... | // startProfiling begins CPU profiling and returns a `stop` function to be
// executed as late as possible. The stop function captures the memprofile. | [
"startProfiling",
"begins",
"CPU",
"profiling",
"and",
"returns",
"a",
"stop",
"function",
"to",
"be",
"executed",
"as",
"late",
"as",
"possible",
".",
"The",
"stop",
"function",
"captures",
"the",
"memprofile",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/cmd/ipfs/main.go#L320-L345 |
127,524 | ipfs/go-ipfs | cmd/ipfs/main.go | getAPIClient | func getAPIClient(ctx context.Context, repoPath, apiAddrStr string) (http.Client, error) {
var apiErrorFmt string
switch {
case osh.IsUnix():
apiErrorFmt = apiFileErrorFmt + checkIPFSUnixFmt
case osh.IsWindows():
apiErrorFmt = apiFileErrorFmt + checkIPFSWinFmt
default:
apiErrorFmt = apiFileErrorFmt
}
var ... | go | func getAPIClient(ctx context.Context, repoPath, apiAddrStr string) (http.Client, error) {
var apiErrorFmt string
switch {
case osh.IsUnix():
apiErrorFmt = apiFileErrorFmt + checkIPFSUnixFmt
case osh.IsWindows():
apiErrorFmt = apiFileErrorFmt + checkIPFSWinFmt
default:
apiErrorFmt = apiFileErrorFmt
}
var ... | [
"func",
"getAPIClient",
"(",
"ctx",
"context",
".",
"Context",
",",
"repoPath",
",",
"apiAddrStr",
"string",
")",
"(",
"http",
".",
"Client",
",",
"error",
")",
"{",
"var",
"apiErrorFmt",
"string",
"\n",
"switch",
"{",
"case",
"osh",
".",
"IsUnix",
"(",
... | // getAPIClient checks the repo, and the given options, checking for
// a running API service. if there is one, it returns a client.
// otherwise, it returns errApiNotRunning, or another error. | [
"getAPIClient",
"checks",
"the",
"repo",
"and",
"the",
"given",
"options",
"checking",
"for",
"a",
"running",
"API",
"service",
".",
"if",
"there",
"is",
"one",
"it",
"returns",
"a",
"client",
".",
"otherwise",
"it",
"returns",
"errApiNotRunning",
"or",
"ano... | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/cmd/ipfs/main.go#L379-L414 |
127,525 | ipfs/go-ipfs | core/coreapi/name.go | Publish | func (api *NameAPI) Publish(ctx context.Context, p path.Path, opts ...caopts.NamePublishOption) (coreiface.IpnsEntry, error) {
if err := api.checkPublishAllowed(); err != nil {
return nil, err
}
options, err := caopts.NamePublishOptions(opts...)
if err != nil {
return nil, err
}
err = api.checkOnline(option... | go | func (api *NameAPI) Publish(ctx context.Context, p path.Path, opts ...caopts.NamePublishOption) (coreiface.IpnsEntry, error) {
if err := api.checkPublishAllowed(); err != nil {
return nil, err
}
options, err := caopts.NamePublishOptions(opts...)
if err != nil {
return nil, err
}
err = api.checkOnline(option... | [
"func",
"(",
"api",
"*",
"NameAPI",
")",
"Publish",
"(",
"ctx",
"context",
".",
"Context",
",",
"p",
"path",
".",
"Path",
",",
"opts",
"...",
"caopts",
".",
"NamePublishOption",
")",
"(",
"coreiface",
".",
"IpnsEntry",
",",
"error",
")",
"{",
"if",
"... | // Publish announces new IPNS name and returns the new IPNS entry. | [
"Publish",
"announces",
"new",
"IPNS",
"name",
"and",
"returns",
"the",
"new",
"IPNS",
"entry",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coreapi/name.go#L39-L83 |
127,526 | ipfs/go-ipfs | repo/fsrepo/datastores.go | Bytes | func (spec DiskSpec) Bytes() []byte {
b, err := json.Marshal(spec)
if err != nil {
// should not happen
panic(err)
}
return bytes.TrimSpace(b)
} | go | func (spec DiskSpec) Bytes() []byte {
b, err := json.Marshal(spec)
if err != nil {
// should not happen
panic(err)
}
return bytes.TrimSpace(b)
} | [
"func",
"(",
"spec",
"DiskSpec",
")",
"Bytes",
"(",
")",
"[",
"]",
"byte",
"{",
"b",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"spec",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// should not happen",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n... | // Bytes returns a minimal JSON encoding of the DiskSpec | [
"Bytes",
"returns",
"a",
"minimal",
"JSON",
"encoding",
"of",
"the",
"DiskSpec"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/datastores.go#L42-L49 |
127,527 | ipfs/go-ipfs | repo/fsrepo/datastores.go | AnyDatastoreConfig | func AnyDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error) {
which, ok := params["type"].(string)
if !ok {
return nil, fmt.Errorf("'type' field missing or not a string")
}
fun, ok := datastores[which]
if !ok {
return nil, fmt.Errorf("unknown datastore type: %s", which)
}
return fun(param... | go | func AnyDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error) {
which, ok := params["type"].(string)
if !ok {
return nil, fmt.Errorf("'type' field missing or not a string")
}
fun, ok := datastores[which]
if !ok {
return nil, fmt.Errorf("unknown datastore type: %s", which)
}
return fun(param... | [
"func",
"AnyDatastoreConfig",
"(",
"params",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"DatastoreConfig",
",",
"error",
")",
"{",
"which",
",",
"ok",
":=",
"params",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
"\n",
"if",
"!",
... | // AnyDatastoreConfig returns a DatastoreConfig from a spec based on
// the "type" parameter | [
"AnyDatastoreConfig",
"returns",
"a",
"DatastoreConfig",
"from",
"a",
"spec",
"based",
"on",
"the",
"type",
"parameter"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/datastores.go#L79-L89 |
127,528 | ipfs/go-ipfs | repo/fsrepo/datastores.go | MountDatastoreConfig | func MountDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error) {
var res mountDatastoreConfig
mounts, ok := params["mounts"].([]interface{})
if !ok {
return nil, fmt.Errorf("'mounts' field is missing or not an array")
}
for _, iface := range mounts {
cfg, ok := iface.(map[string]interface{})... | go | func MountDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error) {
var res mountDatastoreConfig
mounts, ok := params["mounts"].([]interface{})
if !ok {
return nil, fmt.Errorf("'mounts' field is missing or not an array")
}
for _, iface := range mounts {
cfg, ok := iface.(map[string]interface{})... | [
"func",
"MountDatastoreConfig",
"(",
"params",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"DatastoreConfig",
",",
"error",
")",
"{",
"var",
"res",
"mountDatastoreConfig",
"\n",
"mounts",
",",
"ok",
":=",
"params",
"[",
"\"",
"\"",
"]",
"... | // MountDatastoreConfig returns a mount DatastoreConfig from a spec | [
"MountDatastoreConfig",
"returns",
"a",
"mount",
"DatastoreConfig",
"from",
"a",
"spec"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/datastores.go#L101-L134 |
127,529 | ipfs/go-ipfs | repo/fsrepo/datastores.go | LogDatastoreConfig | func LogDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error) {
childField, ok := params["child"].(map[string]interface{})
if !ok {
return nil, fmt.Errorf("'child' field is missing or not a map")
}
child, err := AnyDatastoreConfig(childField)
if err != nil {
return nil, err
}
name, ok := pa... | go | func LogDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error) {
childField, ok := params["child"].(map[string]interface{})
if !ok {
return nil, fmt.Errorf("'child' field is missing or not a map")
}
child, err := AnyDatastoreConfig(childField)
if err != nil {
return nil, err
}
name, ok := pa... | [
"func",
"LogDatastoreConfig",
"(",
"params",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"DatastoreConfig",
",",
"error",
")",
"{",
"childField",
",",
"ok",
":=",
"params",
"[",
"\"",
"\"",
"]",
".",
"(",
"map",
"[",
"string",
"]",
"i... | // LogDatastoreConfig returns a log DatastoreConfig from a spec | [
"LogDatastoreConfig",
"returns",
"a",
"log",
"DatastoreConfig",
"from",
"a",
"spec"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/datastores.go#L187-L202 |
127,530 | ipfs/go-ipfs | repo/fsrepo/datastores.go | MeasureDatastoreConfig | func MeasureDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error) {
childField, ok := params["child"].(map[string]interface{})
if !ok {
return nil, fmt.Errorf("'child' field is missing or not a map")
}
child, err := AnyDatastoreConfig(childField)
if err != nil {
return nil, err
}
prefix, ok... | go | func MeasureDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error) {
childField, ok := params["child"].(map[string]interface{})
if !ok {
return nil, fmt.Errorf("'child' field is missing or not a map")
}
child, err := AnyDatastoreConfig(childField)
if err != nil {
return nil, err
}
prefix, ok... | [
"func",
"MeasureDatastoreConfig",
"(",
"params",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"DatastoreConfig",
",",
"error",
")",
"{",
"childField",
",",
"ok",
":=",
"params",
"[",
"\"",
"\"",
"]",
".",
"(",
"map",
"[",
"string",
"]",
... | // MeasureDatastoreConfig returns a measure DatastoreConfig from a spec | [
"MeasureDatastoreConfig",
"returns",
"a",
"measure",
"DatastoreConfig",
"from",
"a",
"spec"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/datastores.go#L222-L236 |
127,531 | ipfs/go-ipfs | core/commands/config.go | scrubPrivKey | func scrubPrivKey(cfg *config.Config) (map[string]interface{}, error) {
cfgMap, err := config.ToMap(cfg)
if err != nil {
return nil, err
}
err = scrubValue(cfgMap, []string{config.IdentityTag, config.PrivKeyTag})
if err != nil {
return nil, err
}
return cfgMap, nil
} | go | func scrubPrivKey(cfg *config.Config) (map[string]interface{}, error) {
cfgMap, err := config.ToMap(cfg)
if err != nil {
return nil, err
}
err = scrubValue(cfgMap, []string{config.IdentityTag, config.PrivKeyTag})
if err != nil {
return nil, err
}
return cfgMap, nil
} | [
"func",
"scrubPrivKey",
"(",
"cfg",
"*",
"config",
".",
"Config",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"cfgMap",
",",
"err",
":=",
"config",
".",
"ToMap",
"(",
"cfg",
")",
"\n",
"if",
"err",
"!=",
"n... | // scrubPrivKey scrubs private key for security reasons. | [
"scrubPrivKey",
"scrubs",
"private",
"key",
"for",
"security",
"reasons",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/config.go#L377-L389 |
127,532 | ipfs/go-ipfs | core/commands/config.go | transformConfig | func transformConfig(configRoot string, configName string, transformer config.Transformer, dryRun bool) (*config.Config, *config.Config, error) {
r, err := fsrepo.Open(configRoot)
if err != nil {
return nil, nil, err
}
defer r.Close()
oldCfg, err := r.Config()
if err != nil {
return nil, nil, err
}
// mak... | go | func transformConfig(configRoot string, configName string, transformer config.Transformer, dryRun bool) (*config.Config, *config.Config, error) {
r, err := fsrepo.Open(configRoot)
if err != nil {
return nil, nil, err
}
defer r.Close()
oldCfg, err := r.Config()
if err != nil {
return nil, nil, err
}
// mak... | [
"func",
"transformConfig",
"(",
"configRoot",
"string",
",",
"configName",
"string",
",",
"transformer",
"config",
".",
"Transformer",
",",
"dryRun",
"bool",
")",
"(",
"*",
"config",
".",
"Config",
",",
"*",
"config",
".",
"Config",
",",
"error",
")",
"{",... | // transformConfig returns old config and new config instead of difference between they,
// because apply command can provide stable API through this way.
// If dryRun is true, repo's config should not be updated and persisted
// to storage. Otherwise, repo's config should be updated and persisted
// to storage. | [
"transformConfig",
"returns",
"old",
"config",
"and",
"new",
"config",
"instead",
"of",
"difference",
"between",
"they",
"because",
"apply",
"command",
"can",
"provide",
"stable",
"API",
"through",
"this",
"way",
".",
"If",
"dryRun",
"is",
"true",
"repo",
"s",... | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/config.go#L396-L432 |
127,533 | ipfs/go-ipfs | p2p/stream.go | Register | func (r *StreamRegistry) Register(streamInfo *Stream) {
r.Lock()
defer r.Unlock()
r.ConnManager.TagPeer(streamInfo.peer, cmgrTag, 20)
r.conns[streamInfo.peer]++
streamInfo.id = r.nextID
r.Streams[r.nextID] = streamInfo
r.nextID++
streamInfo.startStreaming()
} | go | func (r *StreamRegistry) Register(streamInfo *Stream) {
r.Lock()
defer r.Unlock()
r.ConnManager.TagPeer(streamInfo.peer, cmgrTag, 20)
r.conns[streamInfo.peer]++
streamInfo.id = r.nextID
r.Streams[r.nextID] = streamInfo
r.nextID++
streamInfo.startStreaming()
} | [
"func",
"(",
"r",
"*",
"StreamRegistry",
")",
"Register",
"(",
"streamInfo",
"*",
"Stream",
")",
"{",
"r",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"Unlock",
"(",
")",
"\n\n",
"r",
".",
"ConnManager",
".",
"TagPeer",
"(",
"streamInfo",
".",
... | // Register registers a stream to the registry | [
"Register",
"registers",
"a",
"stream",
"to",
"the",
"registry"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/p2p/stream.go#L75-L87 |
127,534 | ipfs/go-ipfs | p2p/stream.go | Deregister | func (r *StreamRegistry) Deregister(streamID uint64) {
r.Lock()
defer r.Unlock()
s, ok := r.Streams[streamID]
if !ok {
return
}
p := s.peer
r.conns[p]--
if r.conns[p] < 1 {
delete(r.conns, p)
r.ConnManager.UntagPeer(p, cmgrTag)
}
delete(r.Streams, streamID)
} | go | func (r *StreamRegistry) Deregister(streamID uint64) {
r.Lock()
defer r.Unlock()
s, ok := r.Streams[streamID]
if !ok {
return
}
p := s.peer
r.conns[p]--
if r.conns[p] < 1 {
delete(r.conns, p)
r.ConnManager.UntagPeer(p, cmgrTag)
}
delete(r.Streams, streamID)
} | [
"func",
"(",
"r",
"*",
"StreamRegistry",
")",
"Deregister",
"(",
"streamID",
"uint64",
")",
"{",
"r",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"Unlock",
"(",
")",
"\n\n",
"s",
",",
"ok",
":=",
"r",
".",
"Streams",
"[",
"streamID",
"]",
"\n... | // Deregister deregisters stream from the registry | [
"Deregister",
"deregisters",
"stream",
"from",
"the",
"registry"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/p2p/stream.go#L90-L106 |
127,535 | ipfs/go-ipfs | provider/provider.go | NewProvider | func NewProvider(ctx context.Context, queue *Queue, contentRouting routing.ContentRouting) Provider {
return &provider{
ctx: ctx,
queue: queue,
contentRouting: contentRouting,
}
} | go | func NewProvider(ctx context.Context, queue *Queue, contentRouting routing.ContentRouting) Provider {
return &provider{
ctx: ctx,
queue: queue,
contentRouting: contentRouting,
}
} | [
"func",
"NewProvider",
"(",
"ctx",
"context",
".",
"Context",
",",
"queue",
"*",
"Queue",
",",
"contentRouting",
"routing",
".",
"ContentRouting",
")",
"Provider",
"{",
"return",
"&",
"provider",
"{",
"ctx",
":",
"ctx",
",",
"queue",
":",
"queue",
",",
"... | // NewProvider creates a provider that announces blocks to the network using a content router | [
"NewProvider",
"creates",
"a",
"provider",
"that",
"announces",
"blocks",
"to",
"the",
"network",
"using",
"a",
"content",
"router"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/provider/provider.go#L36-L42 |
127,536 | ipfs/go-ipfs | provider/provider.go | Provide | func (p *provider) Provide(root cid.Cid) error {
p.queue.Enqueue(root)
return nil
} | go | func (p *provider) Provide(root cid.Cid) error {
p.queue.Enqueue(root)
return nil
} | [
"func",
"(",
"p",
"*",
"provider",
")",
"Provide",
"(",
"root",
"cid",
".",
"Cid",
")",
"error",
"{",
"p",
".",
"queue",
".",
"Enqueue",
"(",
"root",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Provide the given cid using specified strategy. | [
"Provide",
"the",
"given",
"cid",
"using",
"specified",
"strategy",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/provider/provider.go#L56-L59 |
127,537 | ipfs/go-ipfs | namesys/namesys.go | NewNameSystem | func NewNameSystem(r routing.ValueStore, ds ds.Datastore, cachesize int) NameSystem {
var cache *lru.Cache
if cachesize > 0 {
cache, _ = lru.New(cachesize)
}
return &mpns{
dnsResolver: NewDNSResolver(),
proquintResolver: new(ProquintResolver),
ipnsResolver: NewIpnsResolver(r),
ipnsPublisher: ... | go | func NewNameSystem(r routing.ValueStore, ds ds.Datastore, cachesize int) NameSystem {
var cache *lru.Cache
if cachesize > 0 {
cache, _ = lru.New(cachesize)
}
return &mpns{
dnsResolver: NewDNSResolver(),
proquintResolver: new(ProquintResolver),
ipnsResolver: NewIpnsResolver(r),
ipnsPublisher: ... | [
"func",
"NewNameSystem",
"(",
"r",
"routing",
".",
"ValueStore",
",",
"ds",
"ds",
".",
"Datastore",
",",
"cachesize",
"int",
")",
"NameSystem",
"{",
"var",
"cache",
"*",
"lru",
".",
"Cache",
"\n",
"if",
"cachesize",
">",
"0",
"{",
"cache",
",",
"_",
... | // NewNameSystem will construct the IPFS naming system based on Routing | [
"NewNameSystem",
"will",
"construct",
"the",
"IPFS",
"naming",
"system",
"based",
"on",
"Routing"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/namesys/namesys.go#L36-L49 |
127,538 | ipfs/go-ipfs | namesys/namesys.go | Publish | func (ns *mpns) Publish(ctx context.Context, name ci.PrivKey, value path.Path) error {
return ns.PublishWithEOL(ctx, name, value, time.Now().Add(DefaultRecordEOL))
} | go | func (ns *mpns) Publish(ctx context.Context, name ci.PrivKey, value path.Path) error {
return ns.PublishWithEOL(ctx, name, value, time.Now().Add(DefaultRecordEOL))
} | [
"func",
"(",
"ns",
"*",
"mpns",
")",
"Publish",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"ci",
".",
"PrivKey",
",",
"value",
"path",
".",
"Path",
")",
"error",
"{",
"return",
"ns",
".",
"PublishWithEOL",
"(",
"ctx",
",",
"name",
",",
"va... | // Publish implements Publisher | [
"Publish",
"implements",
"Publisher"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/namesys/namesys.go#L173-L175 |
127,539 | ipfs/go-ipfs | pin/gc/gc.go | Descendants | func Descendants(ctx context.Context, getLinks dag.GetLinks, set *cid.Set, roots []cid.Cid) error {
verifyGetLinks := func(ctx context.Context, c cid.Cid) ([]*ipld.Link, error) {
err := verifcid.ValidateCid(c)
if err != nil {
return nil, err
}
return getLinks(ctx, c)
}
verboseCidError := func(err error)... | go | func Descendants(ctx context.Context, getLinks dag.GetLinks, set *cid.Set, roots []cid.Cid) error {
verifyGetLinks := func(ctx context.Context, c cid.Cid) ([]*ipld.Link, error) {
err := verifcid.ValidateCid(c)
if err != nil {
return nil, err
}
return getLinks(ctx, c)
}
verboseCidError := func(err error)... | [
"func",
"Descendants",
"(",
"ctx",
"context",
".",
"Context",
",",
"getLinks",
"dag",
".",
"GetLinks",
",",
"set",
"*",
"cid",
".",
"Set",
",",
"roots",
"[",
"]",
"cid",
".",
"Cid",
")",
"error",
"{",
"verifyGetLinks",
":=",
"func",
"(",
"ctx",
"cont... | // Descendants recursively finds all the descendants of the given roots and
// adds them to the given cid.Set, using the provided dag.GetLinks function
// to walk the tree. | [
"Descendants",
"recursively",
"finds",
"all",
"the",
"descendants",
"of",
"the",
"given",
"roots",
"and",
"adds",
"them",
"to",
"the",
"given",
"cid",
".",
"Set",
"using",
"the",
"provided",
"dag",
".",
"GetLinks",
"function",
"to",
"walk",
"the",
"tree",
... | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/pin/gc/gc.go#L151-L185 |
127,540 | ipfs/go-ipfs | pin/gc/gc.go | ColoredSet | func ColoredSet(ctx context.Context, pn pin.Pinner, ng ipld.NodeGetter, bestEffortRoots []cid.Cid, output chan<- Result) (*cid.Set, error) {
// KeySet currently implemented in memory, in the future, may be bloom filter or
// disk backed to conserve memory.
errors := false
gcs := cid.NewSet()
getLinks := func(ctx c... | go | func ColoredSet(ctx context.Context, pn pin.Pinner, ng ipld.NodeGetter, bestEffortRoots []cid.Cid, output chan<- Result) (*cid.Set, error) {
// KeySet currently implemented in memory, in the future, may be bloom filter or
// disk backed to conserve memory.
errors := false
gcs := cid.NewSet()
getLinks := func(ctx c... | [
"func",
"ColoredSet",
"(",
"ctx",
"context",
".",
"Context",
",",
"pn",
"pin",
".",
"Pinner",
",",
"ng",
"ipld",
".",
"NodeGetter",
",",
"bestEffortRoots",
"[",
"]",
"cid",
".",
"Cid",
",",
"output",
"chan",
"<-",
"Result",
")",
"(",
"*",
"cid",
".",... | // ColoredSet computes the set of nodes in the graph that are pinned by the
// pins in the given pinner. | [
"ColoredSet",
"computes",
"the",
"set",
"of",
"nodes",
"in",
"the",
"graph",
"that",
"are",
"pinned",
"by",
"the",
"pins",
"in",
"the",
"given",
"pinner",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/pin/gc/gc.go#L189-L257 |
127,541 | ipfs/go-ipfs | core/node/identity.go | PrivateKey | func PrivateKey(sk crypto.PrivKey) func(id peer.ID) (crypto.PrivKey, error) {
return func(id peer.ID) (crypto.PrivKey, error) {
id2, err := peer.IDFromPrivateKey(sk)
if err != nil {
return nil, err
}
if id2 != id {
return nil, fmt.Errorf("private key in config does not match id: %s != %s", id, id2)
}
... | go | func PrivateKey(sk crypto.PrivKey) func(id peer.ID) (crypto.PrivKey, error) {
return func(id peer.ID) (crypto.PrivKey, error) {
id2, err := peer.IDFromPrivateKey(sk)
if err != nil {
return nil, err
}
if id2 != id {
return nil, fmt.Errorf("private key in config does not match id: %s != %s", id, id2)
}
... | [
"func",
"PrivateKey",
"(",
"sk",
"crypto",
".",
"PrivKey",
")",
"func",
"(",
"id",
"peer",
".",
"ID",
")",
"(",
"crypto",
".",
"PrivKey",
",",
"error",
")",
"{",
"return",
"func",
"(",
"id",
"peer",
".",
"ID",
")",
"(",
"crypto",
".",
"PrivKey",
... | // PrivateKey loads the private key from config | [
"PrivateKey",
"loads",
"the",
"private",
"key",
"from",
"config"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/identity.go#L17-L29 |
127,542 | ipfs/go-ipfs | fuse/ipns/ipns_unix.go | NewFileSystem | func NewFileSystem(ipfs *core.IpfsNode, sk ci.PrivKey, ipfspath, ipnspath string) (*FileSystem, error) {
kmap := map[string]ci.PrivKey{
"local": sk,
}
root, err := CreateRoot(ipfs, kmap, ipfspath, ipnspath)
if err != nil {
return nil, err
}
return &FileSystem{Ipfs: ipfs, RootNode: root}, nil
} | go | func NewFileSystem(ipfs *core.IpfsNode, sk ci.PrivKey, ipfspath, ipnspath string) (*FileSystem, error) {
kmap := map[string]ci.PrivKey{
"local": sk,
}
root, err := CreateRoot(ipfs, kmap, ipfspath, ipnspath)
if err != nil {
return nil, err
}
return &FileSystem{Ipfs: ipfs, RootNode: root}, nil
} | [
"func",
"NewFileSystem",
"(",
"ipfs",
"*",
"core",
".",
"IpfsNode",
",",
"sk",
"ci",
".",
"PrivKey",
",",
"ipfspath",
",",
"ipnspath",
"string",
")",
"(",
"*",
"FileSystem",
",",
"error",
")",
"{",
"kmap",
":=",
"map",
"[",
"string",
"]",
"ci",
".",
... | // NewFileSystem constructs new fs using given core.IpfsNode instance. | [
"NewFileSystem",
"constructs",
"new",
"fs",
"using",
"given",
"core",
".",
"IpfsNode",
"instance",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/fuse/ipns/ipns_unix.go#L48-L59 |
127,543 | ipfs/go-ipfs | fuse/ipns/ipns_unix.go | Attr | func (*Root) Attr(ctx context.Context, a *fuse.Attr) error {
log.Debug("Root Attr")
a.Mode = os.ModeDir | 0111 // -rw+x
return nil
} | go | func (*Root) Attr(ctx context.Context, a *fuse.Attr) error {
log.Debug("Root Attr")
a.Mode = os.ModeDir | 0111 // -rw+x
return nil
} | [
"func",
"(",
"*",
"Root",
")",
"Attr",
"(",
"ctx",
"context",
".",
"Context",
",",
"a",
"*",
"fuse",
".",
"Attr",
")",
"error",
"{",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"a",
".",
"Mode",
"=",
"os",
".",
"ModeDir",
"|",
"0111",
"/... | // Attr returns file attributes. | [
"Attr",
"returns",
"file",
"attributes",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/fuse/ipns/ipns_unix.go#L170-L174 |
127,544 | ipfs/go-ipfs | fuse/ipns/ipns_unix.go | ReadDirAll | func (r *Root) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
log.Debug("Root ReadDirAll")
var listing []fuse.Dirent
for alias, k := range r.Keys {
pid, err := peer.IDFromPrivateKey(k)
if err != nil {
continue
}
ent := fuse.Dirent{
Name: pid.Pretty(),
Type: fuse.DT_Dir,
}
link := fuse... | go | func (r *Root) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
log.Debug("Root ReadDirAll")
var listing []fuse.Dirent
for alias, k := range r.Keys {
pid, err := peer.IDFromPrivateKey(k)
if err != nil {
continue
}
ent := fuse.Dirent{
Name: pid.Pretty(),
Type: fuse.DT_Dir,
}
link := fuse... | [
"func",
"(",
"r",
"*",
"Root",
")",
"ReadDirAll",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"fuse",
".",
"Dirent",
",",
"error",
")",
"{",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\n",
"var",
"listing",
"[",
"]",
"fuse",
"... | // ReadDirAll reads a particular directory. Will show locally available keys
// as well as a symlink to the peerID key | [
"ReadDirAll",
"reads",
"a",
"particular",
"directory",
".",
"Will",
"show",
"locally",
"available",
"keys",
"as",
"well",
"as",
"a",
"symlink",
"to",
"the",
"peerID",
"key"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/fuse/ipns/ipns_unix.go#L239-L259 |
127,545 | ipfs/go-ipfs | fuse/ipns/ipns_unix.go | Fsync | func (fi *FileNode) Fsync(ctx context.Context, req *fuse.FsyncRequest) error {
// This needs to perform a *full* flush because, in MFS, a write isn't
// persisted until the root is updated.
errs := make(chan error, 1)
go func() {
errs <- fi.fi.Flush()
}()
select {
case err := <-errs:
return err
case <-ctx.D... | go | func (fi *FileNode) Fsync(ctx context.Context, req *fuse.FsyncRequest) error {
// This needs to perform a *full* flush because, in MFS, a write isn't
// persisted until the root is updated.
errs := make(chan error, 1)
go func() {
errs <- fi.fi.Flush()
}()
select {
case err := <-errs:
return err
case <-ctx.D... | [
"func",
"(",
"fi",
"*",
"FileNode",
")",
"Fsync",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"fuse",
".",
"FsyncRequest",
")",
"error",
"{",
"// This needs to perform a *full* flush because, in MFS, a write isn't",
"// persisted until the root is updated.",
... | // Fsync flushes the content in the file to disk. | [
"Fsync",
"flushes",
"the",
"content",
"in",
"the",
"file",
"to",
"disk",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/fuse/ipns/ipns_unix.go#L408-L421 |
127,546 | ipfs/go-ipfs | fuse/ipns/ipns_unix.go | Rename | func (dir *Directory) Rename(ctx context.Context, req *fuse.RenameRequest, newDir fs.Node) error {
cur, err := dir.dir.Child(req.OldName)
if err != nil {
return err
}
err = dir.dir.Unlink(req.OldName)
if err != nil {
return err
}
switch newDir := newDir.(type) {
case *Directory:
nd, err := cur.GetNode()... | go | func (dir *Directory) Rename(ctx context.Context, req *fuse.RenameRequest, newDir fs.Node) error {
cur, err := dir.dir.Child(req.OldName)
if err != nil {
return err
}
err = dir.dir.Unlink(req.OldName)
if err != nil {
return err
}
switch newDir := newDir.(type) {
case *Directory:
nd, err := cur.GetNode()... | [
"func",
"(",
"dir",
"*",
"Directory",
")",
"Rename",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"fuse",
".",
"RenameRequest",
",",
"newDir",
"fs",
".",
"Node",
")",
"error",
"{",
"cur",
",",
"err",
":=",
"dir",
".",
"dir",
".",
"Child"... | // Rename implements NodeRenamer | [
"Rename",
"implements",
"NodeRenamer"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/fuse/ipns/ipns_unix.go#L522-L552 |
127,547 | ipfs/go-ipfs | dagutils/diff.go | String | func (c *Change) String() string {
switch c.Type {
case Add:
return fmt.Sprintf("Added %s at %s", c.After.String(), c.Path)
case Remove:
return fmt.Sprintf("Removed %s from %s", c.Before.String(), c.Path)
case Mod:
return fmt.Sprintf("Changed %s to %s at %s", c.Before.String(), c.After.String(), c.Path)
defa... | go | func (c *Change) String() string {
switch c.Type {
case Add:
return fmt.Sprintf("Added %s at %s", c.After.String(), c.Path)
case Remove:
return fmt.Sprintf("Removed %s from %s", c.Before.String(), c.Path)
case Mod:
return fmt.Sprintf("Changed %s to %s at %s", c.Before.String(), c.After.String(), c.Path)
defa... | [
"func",
"(",
"c",
"*",
"Change",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"c",
".",
"Type",
"{",
"case",
"Add",
":",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"After",
".",
"String",
"(",
")",
",",
"c",
".",
"P... | // String prints a human-friendly line about a change. | [
"String",
"prints",
"a",
"human",
"-",
"friendly",
"line",
"about",
"a",
"change",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/dagutils/diff.go#L31-L42 |
127,548 | ipfs/go-ipfs | dagutils/diff.go | ApplyChange | func ApplyChange(ctx context.Context, ds ipld.DAGService, nd *dag.ProtoNode, cs []*Change) (*dag.ProtoNode, error) {
e := NewDagEditor(nd, ds)
for _, c := range cs {
switch c.Type {
case Add:
child, err := ds.Get(ctx, c.After)
if err != nil {
return nil, err
}
childpb, ok := child.(*dag.ProtoNode... | go | func ApplyChange(ctx context.Context, ds ipld.DAGService, nd *dag.ProtoNode, cs []*Change) (*dag.ProtoNode, error) {
e := NewDagEditor(nd, ds)
for _, c := range cs {
switch c.Type {
case Add:
child, err := ds.Get(ctx, c.After)
if err != nil {
return nil, err
}
childpb, ok := child.(*dag.ProtoNode... | [
"func",
"ApplyChange",
"(",
"ctx",
"context",
".",
"Context",
",",
"ds",
"ipld",
".",
"DAGService",
",",
"nd",
"*",
"dag",
".",
"ProtoNode",
",",
"cs",
"[",
"]",
"*",
"Change",
")",
"(",
"*",
"dag",
".",
"ProtoNode",
",",
"error",
")",
"{",
"e",
... | // ApplyChange applies the requested changes to the given node in the given dag. | [
"ApplyChange",
"applies",
"the",
"requested",
"changes",
"to",
"the",
"given",
"node",
"in",
"the",
"given",
"dag",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/dagutils/diff.go#L45-L94 |
127,549 | ipfs/go-ipfs | core/corehttp/gateway_handler.go | internalWebError | func internalWebError(w http.ResponseWriter, err error) {
webErrorWithCode(w, "internalWebError", err, http.StatusInternalServerError)
} | go | func internalWebError(w http.ResponseWriter, err error) {
webErrorWithCode(w, "internalWebError", err, http.StatusInternalServerError)
} | [
"func",
"internalWebError",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"err",
"error",
")",
"{",
"webErrorWithCode",
"(",
"w",
",",
"\"",
"\"",
",",
"err",
",",
"http",
".",
"StatusInternalServerError",
")",
"\n",
"}"
] | // return a 500 error and log | [
"return",
"a",
"500",
"error",
"and",
"log"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/corehttp/gateway_handler.go#L612-L614 |
127,550 | ipfs/go-ipfs | core/node/helpers.go | Append | func (lp *lcProcess) Append(f goprocess.ProcessFunc) {
// Hooks are guaranteed to run in sequence. If a hook fails to start, its
// OnStop won't be executed.
var proc goprocess.Process
lp.LC.Append(fx.Hook{
OnStart: func(ctx context.Context) error {
proc = lp.Proc.Go(f)
return nil
},
OnStop: func(ctx c... | go | func (lp *lcProcess) Append(f goprocess.ProcessFunc) {
// Hooks are guaranteed to run in sequence. If a hook fails to start, its
// OnStop won't be executed.
var proc goprocess.Process
lp.LC.Append(fx.Hook{
OnStart: func(ctx context.Context) error {
proc = lp.Proc.Go(f)
return nil
},
OnStop: func(ctx c... | [
"func",
"(",
"lp",
"*",
"lcProcess",
")",
"Append",
"(",
"f",
"goprocess",
".",
"ProcessFunc",
")",
"{",
"// Hooks are guaranteed to run in sequence. If a hook fails to start, its",
"// OnStop won't be executed.",
"var",
"proc",
"goprocess",
".",
"Process",
"\n\n",
"lp",
... | // Append wraps ProcessFunc into a goprocess, and appends it to the lifecycle | [
"Append",
"wraps",
"ProcessFunc",
"into",
"a",
"goprocess",
"and",
"appends",
"it",
"to",
"the",
"lifecycle"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/helpers.go#L19-L37 |
127,551 | ipfs/go-ipfs | core/node/helpers.go | baseProcess | func baseProcess(lc fx.Lifecycle) goprocess.Process {
p := goprocess.WithParent(goprocess.Background())
lc.Append(fx.Hook{
OnStop: func(_ context.Context) error {
return p.Close()
},
})
return p
} | go | func baseProcess(lc fx.Lifecycle) goprocess.Process {
p := goprocess.WithParent(goprocess.Background())
lc.Append(fx.Hook{
OnStop: func(_ context.Context) error {
return p.Close()
},
})
return p
} | [
"func",
"baseProcess",
"(",
"lc",
"fx",
".",
"Lifecycle",
")",
"goprocess",
".",
"Process",
"{",
"p",
":=",
"goprocess",
".",
"WithParent",
"(",
"goprocess",
".",
"Background",
"(",
")",
")",
"\n",
"lc",
".",
"Append",
"(",
"fx",
".",
"Hook",
"{",
"O... | // baseProcess creates a goprocess which is closed when the lifecycle signals it to stop | [
"baseProcess",
"creates",
"a",
"goprocess",
"which",
"is",
"closed",
"when",
"the",
"lifecycle",
"signals",
"it",
"to",
"stop"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/node/helpers.go#L54-L62 |
127,552 | ipfs/go-ipfs | dagutils/diffenum.go | DiffEnumerate | func DiffEnumerate(ctx context.Context, dserv ipld.NodeGetter, from, to cid.Cid) error {
fnd, err := dserv.Get(ctx, from)
if err != nil {
return fmt.Errorf("get %s: %s", from, err)
}
tnd, err := dserv.Get(ctx, to)
if err != nil {
return fmt.Errorf("get %s: %s", to, err)
}
diff := getLinkDiff(fnd, tnd)
ss... | go | func DiffEnumerate(ctx context.Context, dserv ipld.NodeGetter, from, to cid.Cid) error {
fnd, err := dserv.Get(ctx, from)
if err != nil {
return fmt.Errorf("get %s: %s", from, err)
}
tnd, err := dserv.Get(ctx, to)
if err != nil {
return fmt.Errorf("get %s: %s", to, err)
}
diff := getLinkDiff(fnd, tnd)
ss... | [
"func",
"DiffEnumerate",
"(",
"ctx",
"context",
".",
"Context",
",",
"dserv",
"ipld",
".",
"NodeGetter",
",",
"from",
",",
"to",
"cid",
".",
"Cid",
")",
"error",
"{",
"fnd",
",",
"err",
":=",
"dserv",
".",
"Get",
"(",
"ctx",
",",
"from",
")",
"\n",... | // DiffEnumerate fetches every object in the graph pointed to by 'to' that is
// not in 'from'. This can be used to more efficiently fetch a graph if you can
// guarantee you already have the entirety of 'from' | [
"DiffEnumerate",
"fetches",
"every",
"object",
"in",
"the",
"graph",
"pointed",
"to",
"by",
"to",
"that",
"is",
"not",
"in",
"from",
".",
"This",
"can",
"be",
"used",
"to",
"more",
"efficiently",
"fetch",
"a",
"graph",
"if",
"you",
"can",
"guarantee",
"y... | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/dagutils/diffenum.go#L16-L56 |
127,553 | ipfs/go-ipfs | dagutils/diffenum.go | getLinkDiff | func getLinkDiff(a, b ipld.Node) []diffpair {
ina := make(map[string]*ipld.Link)
inb := make(map[string]*ipld.Link)
var aonly []cid.Cid
for _, l := range b.Links() {
inb[l.Cid.KeyString()] = l
}
for _, l := range a.Links() {
var key = l.Cid.KeyString()
ina[key] = l
if inb[key] == nil {
aonly = append(a... | go | func getLinkDiff(a, b ipld.Node) []diffpair {
ina := make(map[string]*ipld.Link)
inb := make(map[string]*ipld.Link)
var aonly []cid.Cid
for _, l := range b.Links() {
inb[l.Cid.KeyString()] = l
}
for _, l := range a.Links() {
var key = l.Cid.KeyString()
ina[key] = l
if inb[key] == nil {
aonly = append(a... | [
"func",
"getLinkDiff",
"(",
"a",
",",
"b",
"ipld",
".",
"Node",
")",
"[",
"]",
"diffpair",
"{",
"ina",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"ipld",
".",
"Link",
")",
"\n",
"inb",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
... | // getLinkDiff returns a changeset between nodes 'a' and 'b'. Currently does
// not log deletions as our usecase doesnt call for this. | [
"getLinkDiff",
"returns",
"a",
"changeset",
"between",
"nodes",
"a",
"and",
"b",
".",
"Currently",
"does",
"not",
"log",
"deletions",
"as",
"our",
"usecase",
"doesnt",
"call",
"for",
"this",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/dagutils/diffenum.go#L67-L99 |
127,554 | ipfs/go-ipfs | core/coreapi/provider.go | Provide | func (api *ProviderAPI) Provide(cid cid.Cid) error {
return api.provider.Provide(cid)
} | go | func (api *ProviderAPI) Provide(cid cid.Cid) error {
return api.provider.Provide(cid)
} | [
"func",
"(",
"api",
"*",
"ProviderAPI",
")",
"Provide",
"(",
"cid",
"cid",
".",
"Cid",
")",
"error",
"{",
"return",
"api",
".",
"provider",
".",
"Provide",
"(",
"cid",
")",
"\n",
"}"
] | // Provide the given cid using the current provider | [
"Provide",
"the",
"given",
"cid",
"using",
"the",
"current",
"provider"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coreapi/provider.go#L11-L13 |
127,555 | ipfs/go-ipfs | fuse/mount/mount.go | ForceUnmount | func ForceUnmount(m Mount) error {
point := m.MountPoint()
log.Warningf("Force-Unmounting %s...", point)
cmd, err := UnmountCmd(point)
if err != nil {
return err
}
errc := make(chan error, 1)
go func() {
defer close(errc)
// try vanilla unmount first.
if err := exec.Command("umount", point).Run(); err... | go | func ForceUnmount(m Mount) error {
point := m.MountPoint()
log.Warningf("Force-Unmounting %s...", point)
cmd, err := UnmountCmd(point)
if err != nil {
return err
}
errc := make(chan error, 1)
go func() {
defer close(errc)
// try vanilla unmount first.
if err := exec.Command("umount", point).Run(); err... | [
"func",
"ForceUnmount",
"(",
"m",
"Mount",
")",
"error",
"{",
"point",
":=",
"m",
".",
"MountPoint",
"(",
")",
"\n",
"log",
".",
"Warningf",
"(",
"\"",
"\"",
",",
"point",
")",
"\n\n",
"cmd",
",",
"err",
":=",
"UnmountCmd",
"(",
"point",
")",
"\n",... | // ForceUnmount attempts to forcibly unmount a given mount.
// It does so by calling diskutil or fusermount directly. | [
"ForceUnmount",
"attempts",
"to",
"forcibly",
"unmount",
"a",
"given",
"mount",
".",
"It",
"does",
"so",
"by",
"calling",
"diskutil",
"or",
"fusermount",
"directly",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/fuse/mount/mount.go#L37-L65 |
127,556 | ipfs/go-ipfs | fuse/mount/mount.go | UnmountCmd | func UnmountCmd(point string) (*exec.Cmd, error) {
switch runtime.GOOS {
case "darwin":
return exec.Command("diskutil", "umount", "force", point), nil
case "linux":
return exec.Command("fusermount", "-u", point), nil
default:
return nil, fmt.Errorf("unmount: unimplemented")
}
} | go | func UnmountCmd(point string) (*exec.Cmd, error) {
switch runtime.GOOS {
case "darwin":
return exec.Command("diskutil", "umount", "force", point), nil
case "linux":
return exec.Command("fusermount", "-u", point), nil
default:
return nil, fmt.Errorf("unmount: unimplemented")
}
} | [
"func",
"UnmountCmd",
"(",
"point",
"string",
")",
"(",
"*",
"exec",
".",
"Cmd",
",",
"error",
")",
"{",
"switch",
"runtime",
".",
"GOOS",
"{",
"case",
"\"",
"\"",
":",
"return",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\""... | // UnmountCmd creates an exec.Cmd that is GOOS-specific
// for unmount a FUSE mount | [
"UnmountCmd",
"creates",
"an",
"exec",
".",
"Cmd",
"that",
"is",
"GOOS",
"-",
"specific",
"for",
"unmount",
"a",
"FUSE",
"mount"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/fuse/mount/mount.go#L69-L78 |
127,557 | ipfs/go-ipfs | fuse/mount/mount.go | ForceUnmountManyTimes | func ForceUnmountManyTimes(m Mount, attempts int) error {
var err error
for i := 0; i < attempts; i++ {
err = ForceUnmount(m)
if err == nil {
return err
}
<-time.After(time.Millisecond * 500)
}
return fmt.Errorf("unmount %s failed after 10 seconds of trying", m.MountPoint())
} | go | func ForceUnmountManyTimes(m Mount, attempts int) error {
var err error
for i := 0; i < attempts; i++ {
err = ForceUnmount(m)
if err == nil {
return err
}
<-time.After(time.Millisecond * 500)
}
return fmt.Errorf("unmount %s failed after 10 seconds of trying", m.MountPoint())
} | [
"func",
"ForceUnmountManyTimes",
"(",
"m",
"Mount",
",",
"attempts",
"int",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"attempts",
";",
"i",
"++",
"{",
"err",
"=",
"ForceUnmount",
"(",
"m",
")",
"\n",
"if"... | // ForceUnmountManyTimes attempts to forcibly unmount a given mount,
// many times. It does so by calling diskutil or fusermount directly.
// Attempts a given number of times. | [
"ForceUnmountManyTimes",
"attempts",
"to",
"forcibly",
"unmount",
"a",
"given",
"mount",
"many",
"times",
".",
"It",
"does",
"so",
"by",
"calling",
"diskutil",
"or",
"fusermount",
"directly",
".",
"Attempts",
"a",
"given",
"number",
"of",
"times",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/fuse/mount/mount.go#L83-L94 |
127,558 | shadowsocks/shadowsocks-go | shadowsocks/pipe.go | PipeThenClose | func PipeThenClose(src, dst net.Conn, addTraffic func(int)) {
defer dst.Close()
buf := leakyBuf.Get()
defer leakyBuf.Put(buf)
for {
SetReadTimeout(src)
n, err := src.Read(buf)
if addTraffic != nil {
addTraffic(n)
}
// read may return EOF with n > 0
// should always process n > 0 bytes before handling... | go | func PipeThenClose(src, dst net.Conn, addTraffic func(int)) {
defer dst.Close()
buf := leakyBuf.Get()
defer leakyBuf.Put(buf)
for {
SetReadTimeout(src)
n, err := src.Read(buf)
if addTraffic != nil {
addTraffic(n)
}
// read may return EOF with n > 0
// should always process n > 0 bytes before handling... | [
"func",
"PipeThenClose",
"(",
"src",
",",
"dst",
"net",
".",
"Conn",
",",
"addTraffic",
"func",
"(",
"int",
")",
")",
"{",
"defer",
"dst",
".",
"Close",
"(",
")",
"\n",
"buf",
":=",
"leakyBuf",
".",
"Get",
"(",
")",
"\n",
"defer",
"leakyBuf",
".",
... | // PipeThenClose copies data from src to dst, closes dst when done. | [
"PipeThenClose",
"copies",
"data",
"from",
"src",
"to",
"dst",
"closes",
"dst",
"when",
"done",
"."
] | ac922d10041cf4f04da4f76da7cef5ae26f492dd | https://github.com/shadowsocks/shadowsocks-go/blob/ac922d10041cf4f04da4f76da7cef5ae26f492dd/shadowsocks/pipe.go#L15-L47 |
127,559 | shadowsocks/shadowsocks-go | shadowsocks/encrypt.go | initEncrypt | func (c *Cipher) initEncrypt() (iv []byte, err error) {
if c.iv == nil {
iv = make([]byte, c.info.ivLen)
if _, err := io.ReadFull(rand.Reader, iv); err != nil {
return nil, err
}
c.iv = iv
} else {
iv = c.iv
}
c.enc, err = c.info.newStream(c.key, iv, Encrypt)
return
} | go | func (c *Cipher) initEncrypt() (iv []byte, err error) {
if c.iv == nil {
iv = make([]byte, c.info.ivLen)
if _, err := io.ReadFull(rand.Reader, iv); err != nil {
return nil, err
}
c.iv = iv
} else {
iv = c.iv
}
c.enc, err = c.info.newStream(c.key, iv, Encrypt)
return
} | [
"func",
"(",
"c",
"*",
"Cipher",
")",
"initEncrypt",
"(",
")",
"(",
"iv",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"if",
"c",
".",
"iv",
"==",
"nil",
"{",
"iv",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"c",
".",
"info",
".",
"ivLen"... | // Initializes the block cipher with CFB mode, returns IV. | [
"Initializes",
"the",
"block",
"cipher",
"with",
"CFB",
"mode",
"returns",
"IV",
"."
] | ac922d10041cf4f04da4f76da7cef5ae26f492dd | https://github.com/shadowsocks/shadowsocks-go/blob/ac922d10041cf4f04da4f76da7cef5ae26f492dd/shadowsocks/encrypt.go#L217-L229 |
127,560 | shadowsocks/shadowsocks-go | shadowsocks/encrypt.go | Copy | func (c *Cipher) Copy() *Cipher {
// This optimization maybe not necessary. But without this function, we
// need to maintain a table cache for newTableCipher and use lock to
// protect concurrent access to that cache.
// AES and DES ciphers does not return specific types, so it's difficult
// to create copy. But... | go | func (c *Cipher) Copy() *Cipher {
// This optimization maybe not necessary. But without this function, we
// need to maintain a table cache for newTableCipher and use lock to
// protect concurrent access to that cache.
// AES and DES ciphers does not return specific types, so it's difficult
// to create copy. But... | [
"func",
"(",
"c",
"*",
"Cipher",
")",
"Copy",
"(",
")",
"*",
"Cipher",
"{",
"// This optimization maybe not necessary. But without this function, we",
"// need to maintain a table cache for newTableCipher and use lock to",
"// protect concurrent access to that cache.",
"// AES and DES ... | // Copy creates a new cipher at it's initial state. | [
"Copy",
"creates",
"a",
"new",
"cipher",
"at",
"it",
"s",
"initial",
"state",
"."
] | ac922d10041cf4f04da4f76da7cef5ae26f492dd | https://github.com/shadowsocks/shadowsocks-go/blob/ac922d10041cf4f04da4f76da7cef5ae26f492dd/shadowsocks/encrypt.go#L245-L263 |
127,561 | shadowsocks/shadowsocks-go | cmd/shadowsocks-local/local.go | createServerConn | func createServerConn(rawaddr []byte, addr string) (remote *ss.Conn, err error) {
const baseFailCnt = 20
n := len(servers.srvCipher)
skipped := make([]int, 0)
for i := 0; i < n; i++ {
// skip failed server, but try it with some probability
if servers.failCnt[i] > 0 && rand.Intn(servers.failCnt[i]+baseFailCnt) !... | go | func createServerConn(rawaddr []byte, addr string) (remote *ss.Conn, err error) {
const baseFailCnt = 20
n := len(servers.srvCipher)
skipped := make([]int, 0)
for i := 0; i < n; i++ {
// skip failed server, but try it with some probability
if servers.failCnt[i] > 0 && rand.Intn(servers.failCnt[i]+baseFailCnt) !... | [
"func",
"createServerConn",
"(",
"rawaddr",
"[",
"]",
"byte",
",",
"addr",
"string",
")",
"(",
"remote",
"*",
"ss",
".",
"Conn",
",",
"err",
"error",
")",
"{",
"const",
"baseFailCnt",
"=",
"20",
"\n",
"n",
":=",
"len",
"(",
"servers",
".",
"srvCipher... | // Connection to the server in the order specified in the config. On
// connection failure, try the next server. A failed server will be tried with
// some probability according to its fail count, so we can discover recovered
// servers. | [
"Connection",
"to",
"the",
"server",
"in",
"the",
"order",
"specified",
"in",
"the",
"config",
".",
"On",
"connection",
"failure",
"try",
"the",
"next",
"server",
".",
"A",
"failed",
"server",
"will",
"be",
"tried",
"with",
"some",
"probability",
"according"... | ac922d10041cf4f04da4f76da7cef5ae26f492dd | https://github.com/shadowsocks/shadowsocks-go/blob/ac922d10041cf4f04da4f76da7cef5ae26f492dd/cmd/shadowsocks-local/local.go#L258-L281 |
127,562 | shadowsocks/shadowsocks-go | shadowsocks/leakybuf.go | NewLeakyBuf | func NewLeakyBuf(n, bufSize int) *LeakyBuf {
return &LeakyBuf{
bufSize: bufSize,
freeList: make(chan []byte, n),
}
} | go | func NewLeakyBuf(n, bufSize int) *LeakyBuf {
return &LeakyBuf{
bufSize: bufSize,
freeList: make(chan []byte, n),
}
} | [
"func",
"NewLeakyBuf",
"(",
"n",
",",
"bufSize",
"int",
")",
"*",
"LeakyBuf",
"{",
"return",
"&",
"LeakyBuf",
"{",
"bufSize",
":",
"bufSize",
",",
"freeList",
":",
"make",
"(",
"chan",
"[",
"]",
"byte",
",",
"n",
")",
",",
"}",
"\n",
"}"
] | // NewLeakyBuf creates a leaky buffer which can hold at most n buffer, each
// with bufSize bytes. | [
"NewLeakyBuf",
"creates",
"a",
"leaky",
"buffer",
"which",
"can",
"hold",
"at",
"most",
"n",
"buffer",
"each",
"with",
"bufSize",
"bytes",
"."
] | ac922d10041cf4f04da4f76da7cef5ae26f492dd | https://github.com/shadowsocks/shadowsocks-go/blob/ac922d10041cf4f04da4f76da7cef5ae26f492dd/shadowsocks/leakybuf.go#L16-L21 |
127,563 | shadowsocks/shadowsocks-go | shadowsocks/leakybuf.go | Get | func (lb *LeakyBuf) Get() (b []byte) {
select {
case b = <-lb.freeList:
default:
b = make([]byte, lb.bufSize)
}
return
} | go | func (lb *LeakyBuf) Get() (b []byte) {
select {
case b = <-lb.freeList:
default:
b = make([]byte, lb.bufSize)
}
return
} | [
"func",
"(",
"lb",
"*",
"LeakyBuf",
")",
"Get",
"(",
")",
"(",
"b",
"[",
"]",
"byte",
")",
"{",
"select",
"{",
"case",
"b",
"=",
"<-",
"lb",
".",
"freeList",
":",
"default",
":",
"b",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"lb",
".",
"buf... | // Get returns a buffer from the leaky buffer or create a new buffer. | [
"Get",
"returns",
"a",
"buffer",
"from",
"the",
"leaky",
"buffer",
"or",
"create",
"a",
"new",
"buffer",
"."
] | ac922d10041cf4f04da4f76da7cef5ae26f492dd | https://github.com/shadowsocks/shadowsocks-go/blob/ac922d10041cf4f04da4f76da7cef5ae26f492dd/shadowsocks/leakybuf.go#L24-L31 |
127,564 | shadowsocks/shadowsocks-go | shadowsocks/leakybuf.go | Put | func (lb *LeakyBuf) Put(b []byte) {
if len(b) != lb.bufSize {
panic("invalid buffer size that's put into leaky buffer")
}
select {
case lb.freeList <- b:
default:
}
return
} | go | func (lb *LeakyBuf) Put(b []byte) {
if len(b) != lb.bufSize {
panic("invalid buffer size that's put into leaky buffer")
}
select {
case lb.freeList <- b:
default:
}
return
} | [
"func",
"(",
"lb",
"*",
"LeakyBuf",
")",
"Put",
"(",
"b",
"[",
"]",
"byte",
")",
"{",
"if",
"len",
"(",
"b",
")",
"!=",
"lb",
".",
"bufSize",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"select",
"{",
"case",
"lb",
".",
"freeList",
... | // Put add the buffer into the free buffer pool for reuse. Panic if the buffer
// size is not the same with the leaky buffer's. This is intended to expose
// error usage of leaky buffer. | [
"Put",
"add",
"the",
"buffer",
"into",
"the",
"free",
"buffer",
"pool",
"for",
"reuse",
".",
"Panic",
"if",
"the",
"buffer",
"size",
"is",
"not",
"the",
"same",
"with",
"the",
"leaky",
"buffer",
"s",
".",
"This",
"is",
"intended",
"to",
"expose",
"erro... | ac922d10041cf4f04da4f76da7cef5ae26f492dd | https://github.com/shadowsocks/shadowsocks-go/blob/ac922d10041cf4f04da4f76da7cef5ae26f492dd/shadowsocks/leakybuf.go#L36-L45 |
127,565 | labstack/echo | bind.go | bindUnmarshaler | func bindUnmarshaler(field reflect.Value) (BindUnmarshaler, bool) {
ptr := reflect.New(field.Type())
if ptr.CanInterface() {
iface := ptr.Interface()
if unmarshaler, ok := iface.(BindUnmarshaler); ok {
return unmarshaler, ok
}
}
return nil, false
} | go | func bindUnmarshaler(field reflect.Value) (BindUnmarshaler, bool) {
ptr := reflect.New(field.Type())
if ptr.CanInterface() {
iface := ptr.Interface()
if unmarshaler, ok := iface.(BindUnmarshaler); ok {
return unmarshaler, ok
}
}
return nil, false
} | [
"func",
"bindUnmarshaler",
"(",
"field",
"reflect",
".",
"Value",
")",
"(",
"BindUnmarshaler",
",",
"bool",
")",
"{",
"ptr",
":=",
"reflect",
".",
"New",
"(",
"field",
".",
"Type",
"(",
")",
")",
"\n",
"if",
"ptr",
".",
"CanInterface",
"(",
")",
"{",... | // bindUnmarshaler attempts to unmarshal a reflect.Value into a BindUnmarshaler | [
"bindUnmarshaler",
"attempts",
"to",
"unmarshal",
"a",
"reflect",
".",
"Value",
"into",
"a",
"BindUnmarshaler"
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/bind.go#L203-L212 |
127,566 | labstack/echo | middleware/body_limit.go | BodyLimit | func BodyLimit(limit string) echo.MiddlewareFunc {
c := DefaultBodyLimitConfig
c.Limit = limit
return BodyLimitWithConfig(c)
} | go | func BodyLimit(limit string) echo.MiddlewareFunc {
c := DefaultBodyLimitConfig
c.Limit = limit
return BodyLimitWithConfig(c)
} | [
"func",
"BodyLimit",
"(",
"limit",
"string",
")",
"echo",
".",
"MiddlewareFunc",
"{",
"c",
":=",
"DefaultBodyLimitConfig",
"\n",
"c",
".",
"Limit",
"=",
"limit",
"\n",
"return",
"BodyLimitWithConfig",
"(",
"c",
")",
"\n",
"}"
] | // BodyLimit returns a BodyLimit middleware.
//
// BodyLimit middleware sets the maximum allowed size for a request body, if the
// size exceeds the configured limit, it sends "413 - Request Entity Too Large"
// response. The BodyLimit is determined based on both `Content-Length` request
// header and actual content re... | [
"BodyLimit",
"returns",
"a",
"BodyLimit",
"middleware",
".",
"BodyLimit",
"middleware",
"sets",
"the",
"maximum",
"allowed",
"size",
"for",
"a",
"request",
"body",
"if",
"the",
"size",
"exceeds",
"the",
"configured",
"limit",
"it",
"sends",
"413",
"-",
"Reques... | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/middleware/body_limit.go#L47-L51 |
127,567 | labstack/echo | middleware/util.go | matchSubdomain | func matchSubdomain(domain, pattern string) bool {
if !matchScheme(domain, pattern) {
return false
}
didx := strings.Index(domain, "://")
pidx := strings.Index(pattern, "://")
if didx == -1 || pidx == -1 {
return false
}
domAuth := domain[didx+3:]
// to avoid long loop by invalid long domain
if len(domAuth... | go | func matchSubdomain(domain, pattern string) bool {
if !matchScheme(domain, pattern) {
return false
}
didx := strings.Index(domain, "://")
pidx := strings.Index(pattern, "://")
if didx == -1 || pidx == -1 {
return false
}
domAuth := domain[didx+3:]
// to avoid long loop by invalid long domain
if len(domAuth... | [
"func",
"matchSubdomain",
"(",
"domain",
",",
"pattern",
"string",
")",
"bool",
"{",
"if",
"!",
"matchScheme",
"(",
"domain",
",",
"pattern",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"didx",
":=",
"strings",
".",
"Index",
"(",
"domain",
",",
"\"",... | // matchSubdomain compares authority with wildcard | [
"matchSubdomain",
"compares",
"authority",
"with",
"wildcard"
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/middleware/util.go#L14-L54 |
127,568 | labstack/echo | middleware/proxy.go | NewRandomBalancer | func NewRandomBalancer(targets []*ProxyTarget) ProxyBalancer {
b := &randomBalancer{commonBalancer: new(commonBalancer)}
b.targets = targets
return b
} | go | func NewRandomBalancer(targets []*ProxyTarget) ProxyBalancer {
b := &randomBalancer{commonBalancer: new(commonBalancer)}
b.targets = targets
return b
} | [
"func",
"NewRandomBalancer",
"(",
"targets",
"[",
"]",
"*",
"ProxyTarget",
")",
"ProxyBalancer",
"{",
"b",
":=",
"&",
"randomBalancer",
"{",
"commonBalancer",
":",
"new",
"(",
"commonBalancer",
")",
"}",
"\n",
"b",
".",
"targets",
"=",
"targets",
"\n",
"re... | // NewRandomBalancer returns a random proxy balancer. | [
"NewRandomBalancer",
"returns",
"a",
"random",
"proxy",
"balancer",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/middleware/proxy.go#L132-L136 |
127,569 | labstack/echo | middleware/proxy.go | NewRoundRobinBalancer | func NewRoundRobinBalancer(targets []*ProxyTarget) ProxyBalancer {
b := &roundRobinBalancer{commonBalancer: new(commonBalancer)}
b.targets = targets
return b
} | go | func NewRoundRobinBalancer(targets []*ProxyTarget) ProxyBalancer {
b := &roundRobinBalancer{commonBalancer: new(commonBalancer)}
b.targets = targets
return b
} | [
"func",
"NewRoundRobinBalancer",
"(",
"targets",
"[",
"]",
"*",
"ProxyTarget",
")",
"ProxyBalancer",
"{",
"b",
":=",
"&",
"roundRobinBalancer",
"{",
"commonBalancer",
":",
"new",
"(",
"commonBalancer",
")",
"}",
"\n",
"b",
".",
"targets",
"=",
"targets",
"\n... | // NewRoundRobinBalancer returns a round-robin proxy balancer. | [
"NewRoundRobinBalancer",
"returns",
"a",
"round",
"-",
"robin",
"proxy",
"balancer",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/middleware/proxy.go#L139-L143 |
127,570 | labstack/echo | middleware/proxy.go | AddTarget | func (b *commonBalancer) AddTarget(target *ProxyTarget) bool {
for _, t := range b.targets {
if t.Name == target.Name {
return false
}
}
b.mutex.Lock()
defer b.mutex.Unlock()
b.targets = append(b.targets, target)
return true
} | go | func (b *commonBalancer) AddTarget(target *ProxyTarget) bool {
for _, t := range b.targets {
if t.Name == target.Name {
return false
}
}
b.mutex.Lock()
defer b.mutex.Unlock()
b.targets = append(b.targets, target)
return true
} | [
"func",
"(",
"b",
"*",
"commonBalancer",
")",
"AddTarget",
"(",
"target",
"*",
"ProxyTarget",
")",
"bool",
"{",
"for",
"_",
",",
"t",
":=",
"range",
"b",
".",
"targets",
"{",
"if",
"t",
".",
"Name",
"==",
"target",
".",
"Name",
"{",
"return",
"fals... | // AddTarget adds an upstream target to the list. | [
"AddTarget",
"adds",
"an",
"upstream",
"target",
"to",
"the",
"list",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/middleware/proxy.go#L146-L156 |
127,571 | labstack/echo | middleware/proxy.go | RemoveTarget | func (b *commonBalancer) RemoveTarget(name string) bool {
b.mutex.Lock()
defer b.mutex.Unlock()
for i, t := range b.targets {
if t.Name == name {
b.targets = append(b.targets[:i], b.targets[i+1:]...)
return true
}
}
return false
} | go | func (b *commonBalancer) RemoveTarget(name string) bool {
b.mutex.Lock()
defer b.mutex.Unlock()
for i, t := range b.targets {
if t.Name == name {
b.targets = append(b.targets[:i], b.targets[i+1:]...)
return true
}
}
return false
} | [
"func",
"(",
"b",
"*",
"commonBalancer",
")",
"RemoveTarget",
"(",
"name",
"string",
")",
"bool",
"{",
"b",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"for",
"i",
",",
"t",
":=",
"range",... | // RemoveTarget removes an upstream target from the list. | [
"RemoveTarget",
"removes",
"an",
"upstream",
"target",
"from",
"the",
"list",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/middleware/proxy.go#L159-L169 |
127,572 | labstack/echo | middleware/proxy.go | Next | func (b *randomBalancer) Next(c echo.Context) *ProxyTarget {
if b.random == nil {
b.random = rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
}
b.mutex.RLock()
defer b.mutex.RUnlock()
return b.targets[b.random.Intn(len(b.targets))]
} | go | func (b *randomBalancer) Next(c echo.Context) *ProxyTarget {
if b.random == nil {
b.random = rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
}
b.mutex.RLock()
defer b.mutex.RUnlock()
return b.targets[b.random.Intn(len(b.targets))]
} | [
"func",
"(",
"b",
"*",
"randomBalancer",
")",
"Next",
"(",
"c",
"echo",
".",
"Context",
")",
"*",
"ProxyTarget",
"{",
"if",
"b",
".",
"random",
"==",
"nil",
"{",
"b",
".",
"random",
"=",
"rand",
".",
"New",
"(",
"rand",
".",
"NewSource",
"(",
"in... | // Next randomly returns an upstream target. | [
"Next",
"randomly",
"returns",
"an",
"upstream",
"target",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/middleware/proxy.go#L172-L179 |
127,573 | labstack/echo | middleware/proxy.go | Next | func (b *roundRobinBalancer) Next(c echo.Context) *ProxyTarget {
b.i = b.i % uint32(len(b.targets))
t := b.targets[b.i]
atomic.AddUint32(&b.i, 1)
return t
} | go | func (b *roundRobinBalancer) Next(c echo.Context) *ProxyTarget {
b.i = b.i % uint32(len(b.targets))
t := b.targets[b.i]
atomic.AddUint32(&b.i, 1)
return t
} | [
"func",
"(",
"b",
"*",
"roundRobinBalancer",
")",
"Next",
"(",
"c",
"echo",
".",
"Context",
")",
"*",
"ProxyTarget",
"{",
"b",
".",
"i",
"=",
"b",
".",
"i",
"%",
"uint32",
"(",
"len",
"(",
"b",
".",
"targets",
")",
")",
"\n",
"t",
":=",
"b",
... | // Next returns an upstream target using round-robin technique. | [
"Next",
"returns",
"an",
"upstream",
"target",
"using",
"round",
"-",
"robin",
"technique",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/middleware/proxy.go#L182-L187 |
127,574 | labstack/echo | response.go | Before | func (r *Response) Before(fn func()) {
r.beforeFuncs = append(r.beforeFuncs, fn)
} | go | func (r *Response) Before(fn func()) {
r.beforeFuncs = append(r.beforeFuncs, fn)
} | [
"func",
"(",
"r",
"*",
"Response",
")",
"Before",
"(",
"fn",
"func",
"(",
")",
")",
"{",
"r",
".",
"beforeFuncs",
"=",
"append",
"(",
"r",
".",
"beforeFuncs",
",",
"fn",
")",
"\n",
"}"
] | // Before registers a function which is called just before the response is written. | [
"Before",
"registers",
"a",
"function",
"which",
"is",
"called",
"just",
"before",
"the",
"response",
"is",
"written",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/response.go#L40-L42 |
127,575 | labstack/echo | response.go | After | func (r *Response) After(fn func()) {
r.afterFuncs = append(r.afterFuncs, fn)
} | go | func (r *Response) After(fn func()) {
r.afterFuncs = append(r.afterFuncs, fn)
} | [
"func",
"(",
"r",
"*",
"Response",
")",
"After",
"(",
"fn",
"func",
"(",
")",
")",
"{",
"r",
".",
"afterFuncs",
"=",
"append",
"(",
"r",
".",
"afterFuncs",
",",
"fn",
")",
"\n",
"}"
] | // After registers a function which is called just after the response is written.
// If the `Content-Length` is unknown, none of the after function is executed. | [
"After",
"registers",
"a",
"function",
"which",
"is",
"called",
"just",
"after",
"the",
"response",
"is",
"written",
".",
"If",
"the",
"Content",
"-",
"Length",
"is",
"unknown",
"none",
"of",
"the",
"after",
"function",
"is",
"executed",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/response.go#L46-L48 |
127,576 | labstack/echo | router.go | Add | func (r *Router) Add(method, path string, h HandlerFunc) {
// Validate path
if path == "" {
path = "/"
}
if path[0] != '/' {
path = "/" + path
}
pnames := []string{} // Param names
ppath := path // Pristine path
for i, l := 0, len(path); i < l; i++ {
if path[i] == ':' {
j := i + 1
r.insert(... | go | func (r *Router) Add(method, path string, h HandlerFunc) {
// Validate path
if path == "" {
path = "/"
}
if path[0] != '/' {
path = "/" + path
}
pnames := []string{} // Param names
ppath := path // Pristine path
for i, l := 0, len(path); i < l; i++ {
if path[i] == ':' {
j := i + 1
r.insert(... | [
"func",
"(",
"r",
"*",
"Router",
")",
"Add",
"(",
"method",
",",
"path",
"string",
",",
"h",
"HandlerFunc",
")",
"{",
"// Validate path",
"if",
"path",
"==",
"\"",
"\"",
"{",
"path",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"path",
"[",
"0",
"]",
... | // Add registers a new route for method and path with matching handler. | [
"Add",
"registers",
"a",
"new",
"route",
"for",
"method",
"and",
"path",
"with",
"matching",
"handler",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/router.go#L57-L93 |
127,577 | labstack/echo | middleware/basic_auth.go | BasicAuth | func BasicAuth(fn BasicAuthValidator) echo.MiddlewareFunc {
c := DefaultBasicAuthConfig
c.Validator = fn
return BasicAuthWithConfig(c)
} | go | func BasicAuth(fn BasicAuthValidator) echo.MiddlewareFunc {
c := DefaultBasicAuthConfig
c.Validator = fn
return BasicAuthWithConfig(c)
} | [
"func",
"BasicAuth",
"(",
"fn",
"BasicAuthValidator",
")",
"echo",
".",
"MiddlewareFunc",
"{",
"c",
":=",
"DefaultBasicAuthConfig",
"\n",
"c",
".",
"Validator",
"=",
"fn",
"\n",
"return",
"BasicAuthWithConfig",
"(",
"c",
")",
"\n",
"}"
] | // BasicAuth returns an BasicAuth middleware.
//
// For valid credentials it calls the next handler.
// For missing or invalid credentials, it sends "401 - Unauthorized" response. | [
"BasicAuth",
"returns",
"an",
"BasicAuth",
"middleware",
".",
"For",
"valid",
"credentials",
"it",
"calls",
"the",
"next",
"handler",
".",
"For",
"missing",
"or",
"invalid",
"credentials",
"it",
"sends",
"401",
"-",
"Unauthorized",
"response",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/middleware/basic_auth.go#L47-L51 |
127,578 | labstack/echo | group.go | Group | func (g *Group) Group(prefix string, middleware ...MiddlewareFunc) (sg *Group) {
m := make([]MiddlewareFunc, 0, len(g.middleware)+len(middleware))
m = append(m, g.middleware...)
m = append(m, middleware...)
sg = g.echo.Group(g.prefix+prefix, m...)
sg.host = g.host
return
} | go | func (g *Group) Group(prefix string, middleware ...MiddlewareFunc) (sg *Group) {
m := make([]MiddlewareFunc, 0, len(g.middleware)+len(middleware))
m = append(m, g.middleware...)
m = append(m, middleware...)
sg = g.echo.Group(g.prefix+prefix, m...)
sg.host = g.host
return
} | [
"func",
"(",
"g",
"*",
"Group",
")",
"Group",
"(",
"prefix",
"string",
",",
"middleware",
"...",
"MiddlewareFunc",
")",
"(",
"sg",
"*",
"Group",
")",
"{",
"m",
":=",
"make",
"(",
"[",
"]",
"MiddlewareFunc",
",",
"0",
",",
"len",
"(",
"g",
".",
"m... | // Group creates a new sub-group with prefix and optional sub-group-level middleware. | [
"Group",
"creates",
"a",
"new",
"sub",
"-",
"group",
"with",
"prefix",
"and",
"optional",
"sub",
"-",
"group",
"-",
"level",
"middleware",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/group.go#L96-L103 |
127,579 | labstack/echo | middleware/body_dump.go | BodyDump | func BodyDump(handler BodyDumpHandler) echo.MiddlewareFunc {
c := DefaultBodyDumpConfig
c.Handler = handler
return BodyDumpWithConfig(c)
} | go | func BodyDump(handler BodyDumpHandler) echo.MiddlewareFunc {
c := DefaultBodyDumpConfig
c.Handler = handler
return BodyDumpWithConfig(c)
} | [
"func",
"BodyDump",
"(",
"handler",
"BodyDumpHandler",
")",
"echo",
".",
"MiddlewareFunc",
"{",
"c",
":=",
"DefaultBodyDumpConfig",
"\n",
"c",
".",
"Handler",
"=",
"handler",
"\n",
"return",
"BodyDumpWithConfig",
"(",
"c",
")",
"\n",
"}"
] | // BodyDump returns a BodyDump middleware.
//
// BodyLimit middleware captures the request and response payload and calls the
// registered handler. | [
"BodyDump",
"returns",
"a",
"BodyDump",
"middleware",
".",
"BodyLimit",
"middleware",
"captures",
"the",
"request",
"and",
"response",
"payload",
"and",
"calls",
"the",
"registered",
"handler",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/middleware/body_dump.go#L45-L49 |
127,580 | labstack/echo | middleware/rewrite.go | Rewrite | func Rewrite(rules map[string]string) echo.MiddlewareFunc {
c := DefaultRewriteConfig
c.Rules = rules
return RewriteWithConfig(c)
} | go | func Rewrite(rules map[string]string) echo.MiddlewareFunc {
c := DefaultRewriteConfig
c.Rules = rules
return RewriteWithConfig(c)
} | [
"func",
"Rewrite",
"(",
"rules",
"map",
"[",
"string",
"]",
"string",
")",
"echo",
".",
"MiddlewareFunc",
"{",
"c",
":=",
"DefaultRewriteConfig",
"\n",
"c",
".",
"Rules",
"=",
"rules",
"\n",
"return",
"RewriteWithConfig",
"(",
"c",
")",
"\n",
"}"
] | // Rewrite returns a Rewrite middleware.
//
// Rewrite middleware rewrites the URL path based on the provided rules. | [
"Rewrite",
"returns",
"a",
"Rewrite",
"middleware",
".",
"Rewrite",
"middleware",
"rewrites",
"the",
"URL",
"path",
"based",
"on",
"the",
"provided",
"rules",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/middleware/rewrite.go#L40-L44 |
127,581 | labstack/echo | middleware/method_override.go | MethodFromHeader | func MethodFromHeader(header string) MethodOverrideGetter {
return func(c echo.Context) string {
return c.Request().Header.Get(header)
}
} | go | func MethodFromHeader(header string) MethodOverrideGetter {
return func(c echo.Context) string {
return c.Request().Header.Get(header)
}
} | [
"func",
"MethodFromHeader",
"(",
"header",
"string",
")",
"MethodOverrideGetter",
"{",
"return",
"func",
"(",
"c",
"echo",
".",
"Context",
")",
"string",
"{",
"return",
"c",
".",
"Request",
"(",
")",
".",
"Header",
".",
"Get",
"(",
"header",
")",
"\n",
... | // MethodFromHeader is a `MethodOverrideGetter` that gets overridden method from
// the request header. | [
"MethodFromHeader",
"is",
"a",
"MethodOverrideGetter",
"that",
"gets",
"overridden",
"method",
"from",
"the",
"request",
"header",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/middleware/method_override.go#L72-L76 |
127,582 | labstack/echo | middleware/key_auth.go | KeyAuth | func KeyAuth(fn KeyAuthValidator) echo.MiddlewareFunc {
c := DefaultKeyAuthConfig
c.Validator = fn
return KeyAuthWithConfig(c)
} | go | func KeyAuth(fn KeyAuthValidator) echo.MiddlewareFunc {
c := DefaultKeyAuthConfig
c.Validator = fn
return KeyAuthWithConfig(c)
} | [
"func",
"KeyAuth",
"(",
"fn",
"KeyAuthValidator",
")",
"echo",
".",
"MiddlewareFunc",
"{",
"c",
":=",
"DefaultKeyAuthConfig",
"\n",
"c",
".",
"Validator",
"=",
"fn",
"\n",
"return",
"KeyAuthWithConfig",
"(",
"c",
")",
"\n",
"}"
] | // KeyAuth returns an KeyAuth middleware.
//
// For valid key it calls the next handler.
// For invalid key, it sends "401 - Unauthorized" response.
// For missing key, it sends "400 - Bad Request" response. | [
"KeyAuth",
"returns",
"an",
"KeyAuth",
"middleware",
".",
"For",
"valid",
"key",
"it",
"calls",
"the",
"next",
"handler",
".",
"For",
"invalid",
"key",
"it",
"sends",
"401",
"-",
"Unauthorized",
"response",
".",
"For",
"missing",
"key",
"it",
"sends",
"400... | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/middleware/key_auth.go#L55-L59 |
127,583 | labstack/echo | middleware/key_auth.go | keyFromHeader | func keyFromHeader(header string, authScheme string) keyExtractor {
return func(c echo.Context) (string, error) {
auth := c.Request().Header.Get(header)
if auth == "" {
return "", errors.New("missing key in request header")
}
if header == echo.HeaderAuthorization {
l := len(authScheme)
if len(auth) > ... | go | func keyFromHeader(header string, authScheme string) keyExtractor {
return func(c echo.Context) (string, error) {
auth := c.Request().Header.Get(header)
if auth == "" {
return "", errors.New("missing key in request header")
}
if header == echo.HeaderAuthorization {
l := len(authScheme)
if len(auth) > ... | [
"func",
"keyFromHeader",
"(",
"header",
"string",
",",
"authScheme",
"string",
")",
"keyExtractor",
"{",
"return",
"func",
"(",
"c",
"echo",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"auth",
":=",
"c",
".",
"Request",
"(",
")",
".",
... | // keyFromHeader returns a `keyExtractor` that extracts key from the request header. | [
"keyFromHeader",
"returns",
"a",
"keyExtractor",
"that",
"extracts",
"key",
"from",
"the",
"request",
"header",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/middleware/key_auth.go#L113-L128 |
127,584 | labstack/echo | middleware/key_auth.go | keyFromQuery | func keyFromQuery(param string) keyExtractor {
return func(c echo.Context) (string, error) {
key := c.QueryParam(param)
if key == "" {
return "", errors.New("missing key in the query string")
}
return key, nil
}
} | go | func keyFromQuery(param string) keyExtractor {
return func(c echo.Context) (string, error) {
key := c.QueryParam(param)
if key == "" {
return "", errors.New("missing key in the query string")
}
return key, nil
}
} | [
"func",
"keyFromQuery",
"(",
"param",
"string",
")",
"keyExtractor",
"{",
"return",
"func",
"(",
"c",
"echo",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"key",
":=",
"c",
".",
"QueryParam",
"(",
"param",
")",
"\n",
"if",
"key",
"==",... | // keyFromQuery returns a `keyExtractor` that extracts key from the query string. | [
"keyFromQuery",
"returns",
"a",
"keyExtractor",
"that",
"extracts",
"key",
"from",
"the",
"query",
"string",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/middleware/key_auth.go#L131-L139 |
127,585 | labstack/echo | middleware/key_auth.go | keyFromForm | func keyFromForm(param string) keyExtractor {
return func(c echo.Context) (string, error) {
key := c.FormValue(param)
if key == "" {
return "", errors.New("missing key in the form")
}
return key, nil
}
} | go | func keyFromForm(param string) keyExtractor {
return func(c echo.Context) (string, error) {
key := c.FormValue(param)
if key == "" {
return "", errors.New("missing key in the form")
}
return key, nil
}
} | [
"func",
"keyFromForm",
"(",
"param",
"string",
")",
"keyExtractor",
"{",
"return",
"func",
"(",
"c",
"echo",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"key",
":=",
"c",
".",
"FormValue",
"(",
"param",
")",
"\n",
"if",
"key",
"==",
... | // keyFromForm returns a `keyExtractor` that extracts key from the form. | [
"keyFromForm",
"returns",
"a",
"keyExtractor",
"that",
"extracts",
"key",
"from",
"the",
"form",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/middleware/key_auth.go#L142-L150 |
127,586 | labstack/echo | echo.go | NewContext | func (e *Echo) NewContext(r *http.Request, w http.ResponseWriter) Context {
return &context{
request: r,
response: NewResponse(w, e),
store: make(Map),
echo: e,
pvalues: make([]string, *e.maxParam),
handler: NotFoundHandler,
}
} | go | func (e *Echo) NewContext(r *http.Request, w http.ResponseWriter) Context {
return &context{
request: r,
response: NewResponse(w, e),
store: make(Map),
echo: e,
pvalues: make([]string, *e.maxParam),
handler: NotFoundHandler,
}
} | [
"func",
"(",
"e",
"*",
"Echo",
")",
"NewContext",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"w",
"http",
".",
"ResponseWriter",
")",
"Context",
"{",
"return",
"&",
"context",
"{",
"request",
":",
"r",
",",
"response",
":",
"NewResponse",
"(",
"w",
... | // NewContext returns a Context instance. | [
"NewContext",
"returns",
"a",
"Context",
"instance",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/echo.go#L316-L325 |
127,587 | labstack/echo | echo.go | DefaultHTTPErrorHandler | func (e *Echo) DefaultHTTPErrorHandler(err error, c Context) {
var (
code = http.StatusInternalServerError
msg interface{}
)
if he, ok := err.(*HTTPError); ok {
code = he.Code
msg = he.Message
if he.Internal != nil {
err = fmt.Errorf("%v, %v", err, he.Internal)
}
} else if e.Debug {
msg = err.Err... | go | func (e *Echo) DefaultHTTPErrorHandler(err error, c Context) {
var (
code = http.StatusInternalServerError
msg interface{}
)
if he, ok := err.(*HTTPError); ok {
code = he.Code
msg = he.Message
if he.Internal != nil {
err = fmt.Errorf("%v, %v", err, he.Internal)
}
} else if e.Debug {
msg = err.Err... | [
"func",
"(",
"e",
"*",
"Echo",
")",
"DefaultHTTPErrorHandler",
"(",
"err",
"error",
",",
"c",
"Context",
")",
"{",
"var",
"(",
"code",
"=",
"http",
".",
"StatusInternalServerError",
"\n",
"msg",
"interface",
"{",
"}",
"\n",
")",
"\n\n",
"if",
"he",
","... | // DefaultHTTPErrorHandler is the default HTTP error handler. It sends a JSON response
// with status code. | [
"DefaultHTTPErrorHandler",
"is",
"the",
"default",
"HTTP",
"error",
"handler",
".",
"It",
"sends",
"a",
"JSON",
"response",
"with",
"status",
"code",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/echo.go#L339-L371 |
127,588 | labstack/echo | echo.go | Pre | func (e *Echo) Pre(middleware ...MiddlewareFunc) {
e.premiddleware = append(e.premiddleware, middleware...)
} | go | func (e *Echo) Pre(middleware ...MiddlewareFunc) {
e.premiddleware = append(e.premiddleware, middleware...)
} | [
"func",
"(",
"e",
"*",
"Echo",
")",
"Pre",
"(",
"middleware",
"...",
"MiddlewareFunc",
")",
"{",
"e",
".",
"premiddleware",
"=",
"append",
"(",
"e",
".",
"premiddleware",
",",
"middleware",
"...",
")",
"\n",
"}"
] | // Pre adds middleware to the chain which is run before router. | [
"Pre",
"adds",
"middleware",
"to",
"the",
"chain",
"which",
"is",
"run",
"before",
"router",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/echo.go#L374-L376 |
127,589 | labstack/echo | echo.go | Use | func (e *Echo) Use(middleware ...MiddlewareFunc) {
e.middleware = append(e.middleware, middleware...)
} | go | func (e *Echo) Use(middleware ...MiddlewareFunc) {
e.middleware = append(e.middleware, middleware...)
} | [
"func",
"(",
"e",
"*",
"Echo",
")",
"Use",
"(",
"middleware",
"...",
"MiddlewareFunc",
")",
"{",
"e",
".",
"middleware",
"=",
"append",
"(",
"e",
".",
"middleware",
",",
"middleware",
"...",
")",
"\n",
"}"
] | // Use adds middleware to the chain which is run after router. | [
"Use",
"adds",
"middleware",
"to",
"the",
"chain",
"which",
"is",
"run",
"after",
"router",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/echo.go#L379-L381 |
127,590 | labstack/echo | echo.go | CONNECT | func (e *Echo) CONNECT(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodConnect, path, h, m...)
} | go | func (e *Echo) CONNECT(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodConnect, path, h, m...)
} | [
"func",
"(",
"e",
"*",
"Echo",
")",
"CONNECT",
"(",
"path",
"string",
",",
"h",
"HandlerFunc",
",",
"m",
"...",
"MiddlewareFunc",
")",
"*",
"Route",
"{",
"return",
"e",
".",
"Add",
"(",
"http",
".",
"MethodConnect",
",",
"path",
",",
"h",
",",
"m",... | // CONNECT registers a new CONNECT route for a path with matching handler in the
// router with optional route-level middleware. | [
"CONNECT",
"registers",
"a",
"new",
"CONNECT",
"route",
"for",
"a",
"path",
"with",
"matching",
"handler",
"in",
"the",
"router",
"with",
"optional",
"route",
"-",
"level",
"middleware",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/echo.go#L385-L387 |
127,591 | labstack/echo | echo.go | DELETE | func (e *Echo) DELETE(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodDelete, path, h, m...)
} | go | func (e *Echo) DELETE(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodDelete, path, h, m...)
} | [
"func",
"(",
"e",
"*",
"Echo",
")",
"DELETE",
"(",
"path",
"string",
",",
"h",
"HandlerFunc",
",",
"m",
"...",
"MiddlewareFunc",
")",
"*",
"Route",
"{",
"return",
"e",
".",
"Add",
"(",
"http",
".",
"MethodDelete",
",",
"path",
",",
"h",
",",
"m",
... | // DELETE registers a new DELETE route for a path with matching handler in the router
// with optional route-level middleware. | [
"DELETE",
"registers",
"a",
"new",
"DELETE",
"route",
"for",
"a",
"path",
"with",
"matching",
"handler",
"in",
"the",
"router",
"with",
"optional",
"route",
"-",
"level",
"middleware",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/echo.go#L391-L393 |
127,592 | labstack/echo | echo.go | GET | func (e *Echo) GET(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodGet, path, h, m...)
} | go | func (e *Echo) GET(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodGet, path, h, m...)
} | [
"func",
"(",
"e",
"*",
"Echo",
")",
"GET",
"(",
"path",
"string",
",",
"h",
"HandlerFunc",
",",
"m",
"...",
"MiddlewareFunc",
")",
"*",
"Route",
"{",
"return",
"e",
".",
"Add",
"(",
"http",
".",
"MethodGet",
",",
"path",
",",
"h",
",",
"m",
"..."... | // GET registers a new GET route for a path with matching handler in the router
// with optional route-level middleware. | [
"GET",
"registers",
"a",
"new",
"GET",
"route",
"for",
"a",
"path",
"with",
"matching",
"handler",
"in",
"the",
"router",
"with",
"optional",
"route",
"-",
"level",
"middleware",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/echo.go#L397-L399 |
127,593 | labstack/echo | echo.go | HEAD | func (e *Echo) HEAD(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodHead, path, h, m...)
} | go | func (e *Echo) HEAD(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodHead, path, h, m...)
} | [
"func",
"(",
"e",
"*",
"Echo",
")",
"HEAD",
"(",
"path",
"string",
",",
"h",
"HandlerFunc",
",",
"m",
"...",
"MiddlewareFunc",
")",
"*",
"Route",
"{",
"return",
"e",
".",
"Add",
"(",
"http",
".",
"MethodHead",
",",
"path",
",",
"h",
",",
"m",
"..... | // HEAD registers a new HEAD route for a path with matching handler in the
// router with optional route-level middleware. | [
"HEAD",
"registers",
"a",
"new",
"HEAD",
"route",
"for",
"a",
"path",
"with",
"matching",
"handler",
"in",
"the",
"router",
"with",
"optional",
"route",
"-",
"level",
"middleware",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/echo.go#L403-L405 |
127,594 | labstack/echo | echo.go | OPTIONS | func (e *Echo) OPTIONS(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodOptions, path, h, m...)
} | go | func (e *Echo) OPTIONS(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodOptions, path, h, m...)
} | [
"func",
"(",
"e",
"*",
"Echo",
")",
"OPTIONS",
"(",
"path",
"string",
",",
"h",
"HandlerFunc",
",",
"m",
"...",
"MiddlewareFunc",
")",
"*",
"Route",
"{",
"return",
"e",
".",
"Add",
"(",
"http",
".",
"MethodOptions",
",",
"path",
",",
"h",
",",
"m",... | // OPTIONS registers a new OPTIONS route for a path with matching handler in the
// router with optional route-level middleware. | [
"OPTIONS",
"registers",
"a",
"new",
"OPTIONS",
"route",
"for",
"a",
"path",
"with",
"matching",
"handler",
"in",
"the",
"router",
"with",
"optional",
"route",
"-",
"level",
"middleware",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/echo.go#L409-L411 |
127,595 | labstack/echo | echo.go | PATCH | func (e *Echo) PATCH(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodPatch, path, h, m...)
} | go | func (e *Echo) PATCH(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodPatch, path, h, m...)
} | [
"func",
"(",
"e",
"*",
"Echo",
")",
"PATCH",
"(",
"path",
"string",
",",
"h",
"HandlerFunc",
",",
"m",
"...",
"MiddlewareFunc",
")",
"*",
"Route",
"{",
"return",
"e",
".",
"Add",
"(",
"http",
".",
"MethodPatch",
",",
"path",
",",
"h",
",",
"m",
"... | // PATCH registers a new PATCH route for a path with matching handler in the
// router with optional route-level middleware. | [
"PATCH",
"registers",
"a",
"new",
"PATCH",
"route",
"for",
"a",
"path",
"with",
"matching",
"handler",
"in",
"the",
"router",
"with",
"optional",
"route",
"-",
"level",
"middleware",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/echo.go#L415-L417 |
127,596 | labstack/echo | echo.go | POST | func (e *Echo) POST(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodPost, path, h, m...)
} | go | func (e *Echo) POST(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodPost, path, h, m...)
} | [
"func",
"(",
"e",
"*",
"Echo",
")",
"POST",
"(",
"path",
"string",
",",
"h",
"HandlerFunc",
",",
"m",
"...",
"MiddlewareFunc",
")",
"*",
"Route",
"{",
"return",
"e",
".",
"Add",
"(",
"http",
".",
"MethodPost",
",",
"path",
",",
"h",
",",
"m",
"..... | // POST registers a new POST route for a path with matching handler in the
// router with optional route-level middleware. | [
"POST",
"registers",
"a",
"new",
"POST",
"route",
"for",
"a",
"path",
"with",
"matching",
"handler",
"in",
"the",
"router",
"with",
"optional",
"route",
"-",
"level",
"middleware",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/echo.go#L421-L423 |
127,597 | labstack/echo | echo.go | PUT | func (e *Echo) PUT(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodPut, path, h, m...)
} | go | func (e *Echo) PUT(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodPut, path, h, m...)
} | [
"func",
"(",
"e",
"*",
"Echo",
")",
"PUT",
"(",
"path",
"string",
",",
"h",
"HandlerFunc",
",",
"m",
"...",
"MiddlewareFunc",
")",
"*",
"Route",
"{",
"return",
"e",
".",
"Add",
"(",
"http",
".",
"MethodPut",
",",
"path",
",",
"h",
",",
"m",
"..."... | // PUT registers a new PUT route for a path with matching handler in the
// router with optional route-level middleware. | [
"PUT",
"registers",
"a",
"new",
"PUT",
"route",
"for",
"a",
"path",
"with",
"matching",
"handler",
"in",
"the",
"router",
"with",
"optional",
"route",
"-",
"level",
"middleware",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/echo.go#L427-L429 |
127,598 | labstack/echo | echo.go | TRACE | func (e *Echo) TRACE(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodTrace, path, h, m...)
} | go | func (e *Echo) TRACE(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodTrace, path, h, m...)
} | [
"func",
"(",
"e",
"*",
"Echo",
")",
"TRACE",
"(",
"path",
"string",
",",
"h",
"HandlerFunc",
",",
"m",
"...",
"MiddlewareFunc",
")",
"*",
"Route",
"{",
"return",
"e",
".",
"Add",
"(",
"http",
".",
"MethodTrace",
",",
"path",
",",
"h",
",",
"m",
"... | // TRACE registers a new TRACE route for a path with matching handler in the
// router with optional route-level middleware. | [
"TRACE",
"registers",
"a",
"new",
"TRACE",
"route",
"for",
"a",
"path",
"with",
"matching",
"handler",
"in",
"the",
"router",
"with",
"optional",
"route",
"-",
"level",
"middleware",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/echo.go#L433-L435 |
127,599 | labstack/echo | echo.go | Any | func (e *Echo) Any(path string, handler HandlerFunc, middleware ...MiddlewareFunc) []*Route {
routes := make([]*Route, len(methods))
for i, m := range methods {
routes[i] = e.Add(m, path, handler, middleware...)
}
return routes
} | go | func (e *Echo) Any(path string, handler HandlerFunc, middleware ...MiddlewareFunc) []*Route {
routes := make([]*Route, len(methods))
for i, m := range methods {
routes[i] = e.Add(m, path, handler, middleware...)
}
return routes
} | [
"func",
"(",
"e",
"*",
"Echo",
")",
"Any",
"(",
"path",
"string",
",",
"handler",
"HandlerFunc",
",",
"middleware",
"...",
"MiddlewareFunc",
")",
"[",
"]",
"*",
"Route",
"{",
"routes",
":=",
"make",
"(",
"[",
"]",
"*",
"Route",
",",
"len",
"(",
"me... | // Any registers a new route for all HTTP methods and path with matching handler
// in the router with optional route-level middleware. | [
"Any",
"registers",
"a",
"new",
"route",
"for",
"all",
"HTTP",
"methods",
"and",
"path",
"with",
"matching",
"handler",
"in",
"the",
"router",
"with",
"optional",
"route",
"-",
"level",
"middleware",
"."
] | 5d2c33ad5dbb78540a56dd08d09d91f991bc3156 | https://github.com/labstack/echo/blob/5d2c33ad5dbb78540a56dd08d09d91f991bc3156/echo.go#L439-L445 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.