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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
151,000 | layeh/gumble | gumble/user.go | SetDeafened | func (u *User) SetDeafened(muted bool) {
packet := MumbleProto.UserState{
Session: &u.Session,
Deaf: &muted,
}
u.client.Conn.WriteProto(&packet)
} | go | func (u *User) SetDeafened(muted bool) {
packet := MumbleProto.UserState{
Session: &u.Session,
Deaf: &muted,
}
u.client.Conn.WriteProto(&packet)
} | [
"func",
"(",
"u",
"*",
"User",
")",
"SetDeafened",
"(",
"muted",
"bool",
")",
"{",
"packet",
":=",
"MumbleProto",
".",
"UserState",
"{",
"Session",
":",
"&",
"u",
".",
"Session",
",",
"Deaf",
":",
"&",
"muted",
",",
"}",
"\n",
"u",
".",
"client",
... | // SetDeafened sets whether the user can receive audio or not. | [
"SetDeafened",
"sets",
"whether",
"the",
"user",
"can",
"receive",
"audio",
"or",
"not",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/user.go#L154-L160 |
151,001 | layeh/gumble | gumble/user.go | RequestStats | func (u *User) RequestStats() {
packet := MumbleProto.UserStats{
Session: &u.Session,
}
u.client.Conn.WriteProto(&packet)
} | go | func (u *User) RequestStats() {
packet := MumbleProto.UserStats{
Session: &u.Session,
}
u.client.Conn.WriteProto(&packet)
} | [
"func",
"(",
"u",
"*",
"User",
")",
"RequestStats",
"(",
")",
"{",
"packet",
":=",
"MumbleProto",
".",
"UserStats",
"{",
"Session",
":",
"&",
"u",
".",
"Session",
",",
"}",
"\n",
"u",
".",
"client",
".",
"Conn",
".",
"WriteProto",
"(",
"&",
"packet... | // RequestStats requests that the user's stats be sent to the client. | [
"RequestStats",
"requests",
"that",
"the",
"user",
"s",
"stats",
"be",
"sent",
"to",
"the",
"client",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/user.go#L185-L190 |
151,002 | layeh/gumble | gumble/user.go | Send | func (u *User) Send(message string) {
textMessage := TextMessage{
Users: []*User{u},
Message: message,
}
u.client.Send(&textMessage)
} | go | func (u *User) Send(message string) {
textMessage := TextMessage{
Users: []*User{u},
Message: message,
}
u.client.Send(&textMessage)
} | [
"func",
"(",
"u",
"*",
"User",
")",
"Send",
"(",
"message",
"string",
")",
"{",
"textMessage",
":=",
"TextMessage",
"{",
"Users",
":",
"[",
"]",
"*",
"User",
"{",
"u",
"}",
",",
"Message",
":",
"message",
",",
"}",
"\n",
"u",
".",
"client",
".",
... | // Send will send a text message to the user. | [
"Send",
"will",
"send",
"a",
"text",
"message",
"to",
"the",
"user",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/user.go#L211-L217 |
151,003 | layeh/gumble | gumbleutil/listener.go | OnConnect | func (l Listener) OnConnect(e *gumble.ConnectEvent) {
if l.Connect != nil {
l.Connect(e)
}
} | go | func (l Listener) OnConnect(e *gumble.ConnectEvent) {
if l.Connect != nil {
l.Connect(e)
}
} | [
"func",
"(",
"l",
"Listener",
")",
"OnConnect",
"(",
"e",
"*",
"gumble",
".",
"ConnectEvent",
")",
"{",
"if",
"l",
".",
"Connect",
"!=",
"nil",
"{",
"l",
".",
"Connect",
"(",
"e",
")",
"\n",
"}",
"\n",
"}"
] | // OnConnect implements gumble.EventListener.OnConnect. | [
"OnConnect",
"implements",
"gumble",
".",
"EventListener",
".",
"OnConnect",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleutil/listener.go#L26-L30 |
151,004 | layeh/gumble | gumbleutil/listener.go | OnDisconnect | func (l Listener) OnDisconnect(e *gumble.DisconnectEvent) {
if l.Disconnect != nil {
l.Disconnect(e)
}
} | go | func (l Listener) OnDisconnect(e *gumble.DisconnectEvent) {
if l.Disconnect != nil {
l.Disconnect(e)
}
} | [
"func",
"(",
"l",
"Listener",
")",
"OnDisconnect",
"(",
"e",
"*",
"gumble",
".",
"DisconnectEvent",
")",
"{",
"if",
"l",
".",
"Disconnect",
"!=",
"nil",
"{",
"l",
".",
"Disconnect",
"(",
"e",
")",
"\n",
"}",
"\n",
"}"
] | // OnDisconnect implements gumble.EventListener.OnDisconnect. | [
"OnDisconnect",
"implements",
"gumble",
".",
"EventListener",
".",
"OnDisconnect",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleutil/listener.go#L33-L37 |
151,005 | layeh/gumble | gumbleutil/listener.go | OnTextMessage | func (l Listener) OnTextMessage(e *gumble.TextMessageEvent) {
if l.TextMessage != nil {
l.TextMessage(e)
}
} | go | func (l Listener) OnTextMessage(e *gumble.TextMessageEvent) {
if l.TextMessage != nil {
l.TextMessage(e)
}
} | [
"func",
"(",
"l",
"Listener",
")",
"OnTextMessage",
"(",
"e",
"*",
"gumble",
".",
"TextMessageEvent",
")",
"{",
"if",
"l",
".",
"TextMessage",
"!=",
"nil",
"{",
"l",
".",
"TextMessage",
"(",
"e",
")",
"\n",
"}",
"\n",
"}"
] | // OnTextMessage implements gumble.EventListener.OnTextMessage. | [
"OnTextMessage",
"implements",
"gumble",
".",
"EventListener",
".",
"OnTextMessage",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleutil/listener.go#L40-L44 |
151,006 | layeh/gumble | gumbleutil/listener.go | OnUserChange | func (l Listener) OnUserChange(e *gumble.UserChangeEvent) {
if l.UserChange != nil {
l.UserChange(e)
}
} | go | func (l Listener) OnUserChange(e *gumble.UserChangeEvent) {
if l.UserChange != nil {
l.UserChange(e)
}
} | [
"func",
"(",
"l",
"Listener",
")",
"OnUserChange",
"(",
"e",
"*",
"gumble",
".",
"UserChangeEvent",
")",
"{",
"if",
"l",
".",
"UserChange",
"!=",
"nil",
"{",
"l",
".",
"UserChange",
"(",
"e",
")",
"\n",
"}",
"\n",
"}"
] | // OnUserChange implements gumble.EventListener.OnUserChange. | [
"OnUserChange",
"implements",
"gumble",
".",
"EventListener",
".",
"OnUserChange",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleutil/listener.go#L47-L51 |
151,007 | layeh/gumble | gumbleutil/listener.go | OnChannelChange | func (l Listener) OnChannelChange(e *gumble.ChannelChangeEvent) {
if l.ChannelChange != nil {
l.ChannelChange(e)
}
} | go | func (l Listener) OnChannelChange(e *gumble.ChannelChangeEvent) {
if l.ChannelChange != nil {
l.ChannelChange(e)
}
} | [
"func",
"(",
"l",
"Listener",
")",
"OnChannelChange",
"(",
"e",
"*",
"gumble",
".",
"ChannelChangeEvent",
")",
"{",
"if",
"l",
".",
"ChannelChange",
"!=",
"nil",
"{",
"l",
".",
"ChannelChange",
"(",
"e",
")",
"\n",
"}",
"\n",
"}"
] | // OnChannelChange implements gumble.EventListener.OnChannelChange. | [
"OnChannelChange",
"implements",
"gumble",
".",
"EventListener",
".",
"OnChannelChange",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleutil/listener.go#L54-L58 |
151,008 | layeh/gumble | gumbleutil/listener.go | OnPermissionDenied | func (l Listener) OnPermissionDenied(e *gumble.PermissionDeniedEvent) {
if l.PermissionDenied != nil {
l.PermissionDenied(e)
}
} | go | func (l Listener) OnPermissionDenied(e *gumble.PermissionDeniedEvent) {
if l.PermissionDenied != nil {
l.PermissionDenied(e)
}
} | [
"func",
"(",
"l",
"Listener",
")",
"OnPermissionDenied",
"(",
"e",
"*",
"gumble",
".",
"PermissionDeniedEvent",
")",
"{",
"if",
"l",
".",
"PermissionDenied",
"!=",
"nil",
"{",
"l",
".",
"PermissionDenied",
"(",
"e",
")",
"\n",
"}",
"\n",
"}"
] | // OnPermissionDenied implements gumble.EventListener.OnPermissionDenied. | [
"OnPermissionDenied",
"implements",
"gumble",
".",
"EventListener",
".",
"OnPermissionDenied",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleutil/listener.go#L61-L65 |
151,009 | layeh/gumble | gumbleutil/listener.go | OnUserList | func (l Listener) OnUserList(e *gumble.UserListEvent) {
if l.UserList != nil {
l.UserList(e)
}
} | go | func (l Listener) OnUserList(e *gumble.UserListEvent) {
if l.UserList != nil {
l.UserList(e)
}
} | [
"func",
"(",
"l",
"Listener",
")",
"OnUserList",
"(",
"e",
"*",
"gumble",
".",
"UserListEvent",
")",
"{",
"if",
"l",
".",
"UserList",
"!=",
"nil",
"{",
"l",
".",
"UserList",
"(",
"e",
")",
"\n",
"}",
"\n",
"}"
] | // OnUserList implements gumble.EventListener.OnUserList. | [
"OnUserList",
"implements",
"gumble",
".",
"EventListener",
".",
"OnUserList",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleutil/listener.go#L68-L72 |
151,010 | layeh/gumble | gumbleutil/listener.go | OnACL | func (l Listener) OnACL(e *gumble.ACLEvent) {
if l.ACL != nil {
l.ACL(e)
}
} | go | func (l Listener) OnACL(e *gumble.ACLEvent) {
if l.ACL != nil {
l.ACL(e)
}
} | [
"func",
"(",
"l",
"Listener",
")",
"OnACL",
"(",
"e",
"*",
"gumble",
".",
"ACLEvent",
")",
"{",
"if",
"l",
".",
"ACL",
"!=",
"nil",
"{",
"l",
".",
"ACL",
"(",
"e",
")",
"\n",
"}",
"\n",
"}"
] | // OnACL implements gumble.EventListener.OnACL. | [
"OnACL",
"implements",
"gumble",
".",
"EventListener",
".",
"OnACL",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleutil/listener.go#L75-L79 |
151,011 | layeh/gumble | gumbleutil/listener.go | OnBanList | func (l Listener) OnBanList(e *gumble.BanListEvent) {
if l.BanList != nil {
l.BanList(e)
}
} | go | func (l Listener) OnBanList(e *gumble.BanListEvent) {
if l.BanList != nil {
l.BanList(e)
}
} | [
"func",
"(",
"l",
"Listener",
")",
"OnBanList",
"(",
"e",
"*",
"gumble",
".",
"BanListEvent",
")",
"{",
"if",
"l",
".",
"BanList",
"!=",
"nil",
"{",
"l",
".",
"BanList",
"(",
"e",
")",
"\n",
"}",
"\n",
"}"
] | // OnBanList implements gumble.EventListener.OnBanList. | [
"OnBanList",
"implements",
"gumble",
".",
"EventListener",
".",
"OnBanList",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleutil/listener.go#L82-L86 |
151,012 | layeh/gumble | gumbleutil/listener.go | OnContextActionChange | func (l Listener) OnContextActionChange(e *gumble.ContextActionChangeEvent) {
if l.ContextActionChange != nil {
l.ContextActionChange(e)
}
} | go | func (l Listener) OnContextActionChange(e *gumble.ContextActionChangeEvent) {
if l.ContextActionChange != nil {
l.ContextActionChange(e)
}
} | [
"func",
"(",
"l",
"Listener",
")",
"OnContextActionChange",
"(",
"e",
"*",
"gumble",
".",
"ContextActionChangeEvent",
")",
"{",
"if",
"l",
".",
"ContextActionChange",
"!=",
"nil",
"{",
"l",
".",
"ContextActionChange",
"(",
"e",
")",
"\n",
"}",
"\n",
"}"
] | // OnContextActionChange implements gumble.EventListener.OnContextActionChange. | [
"OnContextActionChange",
"implements",
"gumble",
".",
"EventListener",
".",
"OnContextActionChange",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleutil/listener.go#L89-L93 |
151,013 | layeh/gumble | gumbleutil/listener.go | OnServerConfig | func (l Listener) OnServerConfig(e *gumble.ServerConfigEvent) {
if l.ServerConfig != nil {
l.ServerConfig(e)
}
} | go | func (l Listener) OnServerConfig(e *gumble.ServerConfigEvent) {
if l.ServerConfig != nil {
l.ServerConfig(e)
}
} | [
"func",
"(",
"l",
"Listener",
")",
"OnServerConfig",
"(",
"e",
"*",
"gumble",
".",
"ServerConfigEvent",
")",
"{",
"if",
"l",
".",
"ServerConfig",
"!=",
"nil",
"{",
"l",
".",
"ServerConfig",
"(",
"e",
")",
"\n",
"}",
"\n",
"}"
] | // OnServerConfig implements gumble.EventListener.OnServerConfig. | [
"OnServerConfig",
"implements",
"gumble",
".",
"EventListener",
".",
"OnServerConfig",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleutil/listener.go#L96-L100 |
151,014 | layeh/gumble | gumble/users.go | create | func (u Users) create(session uint32) *User {
user := &User{
Session: session,
}
u[session] = user
return user
} | go | func (u Users) create(session uint32) *User {
user := &User{
Session: session,
}
u[session] = user
return user
} | [
"func",
"(",
"u",
"Users",
")",
"create",
"(",
"session",
"uint32",
")",
"*",
"User",
"{",
"user",
":=",
"&",
"User",
"{",
"Session",
":",
"session",
",",
"}",
"\n",
"u",
"[",
"session",
"]",
"=",
"user",
"\n",
"return",
"user",
"\n",
"}"
] | // create adds a new user with the given session to the collection. If a user
// with the given session already exists, it is overwritten. | [
"create",
"adds",
"a",
"new",
"user",
"with",
"the",
"given",
"session",
"to",
"the",
"collection",
".",
"If",
"a",
"user",
"with",
"the",
"given",
"session",
"already",
"exists",
"it",
"is",
"overwritten",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/users.go#L13-L19 |
151,015 | layeh/gumble | gumble/users.go | Find | func (u Users) Find(name string) *User {
for _, user := range u {
if user.Name == name {
return user
}
}
return nil
} | go | func (u Users) Find(name string) *User {
for _, user := range u {
if user.Name == name {
return user
}
}
return nil
} | [
"func",
"(",
"u",
"Users",
")",
"Find",
"(",
"name",
"string",
")",
"*",
"User",
"{",
"for",
"_",
",",
"user",
":=",
"range",
"u",
"{",
"if",
"user",
".",
"Name",
"==",
"name",
"{",
"return",
"user",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",... | // Find returns the user with the given name. nil is returned if no user exists
// with the given name. | [
"Find",
"returns",
"the",
"user",
"with",
"the",
"given",
"name",
".",
"nil",
"is",
"returned",
"if",
"no",
"user",
"exists",
"with",
"the",
"given",
"name",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/users.go#L23-L30 |
151,016 | layeh/gumble | gumble/varint/write.go | Encode | func Encode(b []byte, value int64) int {
// 111111xx Byte-inverted negative two bit number (~xx)
if value <= -1 && value >= -4 {
b[0] = 0xFC | byte(^value&0xFF)
return 1
}
// 111110__ + varint Negative recursive varint
if value < 0 {
b[0] = 0xF8
return 1 + Encode(b[1:], -value)
}
// 0xxxxxxx 7-bit positive number
if value <= 0x7F {
b[0] = byte(value)
return 1
}
// 10xxxxxx + 1 byte 14-bit positive number
if value <= 0x3FFF {
b[0] = byte(((value >> 8) & 0x3F) | 0x80)
b[1] = byte(value & 0xFF)
return 2
}
// 110xxxxx + 2 bytes 21-bit positive number
if value <= 0x1FFFFF {
b[0] = byte((value>>16)&0x1F | 0xC0)
b[1] = byte((value >> 8) & 0xFF)
b[2] = byte(value & 0xFF)
return 3
}
// 1110xxxx + 3 bytes 28-bit positive number
if value <= 0xFFFFFFF {
b[0] = byte((value>>24)&0xF | 0xE0)
b[1] = byte((value >> 16) & 0xFF)
b[2] = byte((value >> 8) & 0xFF)
b[3] = byte(value & 0xFF)
return 4
}
// 111100__ + int (32-bit) 32-bit positive number
if value <= math.MaxInt32 {
b[0] = 0xF0
binary.BigEndian.PutUint32(b[1:], uint32(value))
return 5
}
// 111101__ + long (64-bit) 64-bit number
if value <= math.MaxInt64 {
b[0] = 0xF4
binary.BigEndian.PutUint64(b[1:], uint64(value))
return 9
}
return 0
} | go | func Encode(b []byte, value int64) int {
// 111111xx Byte-inverted negative two bit number (~xx)
if value <= -1 && value >= -4 {
b[0] = 0xFC | byte(^value&0xFF)
return 1
}
// 111110__ + varint Negative recursive varint
if value < 0 {
b[0] = 0xF8
return 1 + Encode(b[1:], -value)
}
// 0xxxxxxx 7-bit positive number
if value <= 0x7F {
b[0] = byte(value)
return 1
}
// 10xxxxxx + 1 byte 14-bit positive number
if value <= 0x3FFF {
b[0] = byte(((value >> 8) & 0x3F) | 0x80)
b[1] = byte(value & 0xFF)
return 2
}
// 110xxxxx + 2 bytes 21-bit positive number
if value <= 0x1FFFFF {
b[0] = byte((value>>16)&0x1F | 0xC0)
b[1] = byte((value >> 8) & 0xFF)
b[2] = byte(value & 0xFF)
return 3
}
// 1110xxxx + 3 bytes 28-bit positive number
if value <= 0xFFFFFFF {
b[0] = byte((value>>24)&0xF | 0xE0)
b[1] = byte((value >> 16) & 0xFF)
b[2] = byte((value >> 8) & 0xFF)
b[3] = byte(value & 0xFF)
return 4
}
// 111100__ + int (32-bit) 32-bit positive number
if value <= math.MaxInt32 {
b[0] = 0xF0
binary.BigEndian.PutUint32(b[1:], uint32(value))
return 5
}
// 111101__ + long (64-bit) 64-bit number
if value <= math.MaxInt64 {
b[0] = 0xF4
binary.BigEndian.PutUint64(b[1:], uint64(value))
return 9
}
return 0
} | [
"func",
"Encode",
"(",
"b",
"[",
"]",
"byte",
",",
"value",
"int64",
")",
"int",
"{",
"// 111111xx Byte-inverted negative two bit number (~xx)",
"if",
"value",
"<=",
"-",
"1",
"&&",
"value",
">=",
"-",
"4",
"{",
"b",
"[",
"0",
"]",
"=",
"0xFC",
"|",
"b... | // Encode encodes the given value to varint format. | [
"Encode",
"encodes",
"the",
"given",
"value",
"to",
"varint",
"format",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/varint/write.go#L13-L64 |
151,017 | layeh/gumble | gumble/conn.go | NewConn | func NewConn(conn net.Conn) *Conn {
return &Conn{
Conn: conn,
Timeout: time.Second * 20,
MaximumPacketBytes: 1024 * 1024 * 10,
}
} | go | func NewConn(conn net.Conn) *Conn {
return &Conn{
Conn: conn,
Timeout: time.Second * 20,
MaximumPacketBytes: 1024 * 1024 * 10,
}
} | [
"func",
"NewConn",
"(",
"conn",
"net",
".",
"Conn",
")",
"*",
"Conn",
"{",
"return",
"&",
"Conn",
"{",
"Conn",
":",
"conn",
",",
"Timeout",
":",
"time",
".",
"Second",
"*",
"20",
",",
"MaximumPacketBytes",
":",
"1024",
"*",
"1024",
"*",
"10",
",",
... | // NewConn creates a new Conn with the given net.Conn. | [
"NewConn",
"creates",
"a",
"new",
"Conn",
"with",
"the",
"given",
"net",
".",
"Conn",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/conn.go#L31-L37 |
151,018 | layeh/gumble | gumble/conn.go | ReadPacket | func (c *Conn) ReadPacket() (uint16, []byte, error) {
c.Conn.SetReadDeadline(time.Now().Add(c.Timeout))
var header [6]byte
if _, err := io.ReadFull(c.Conn, header[:]); err != nil {
return 0, nil, err
}
pType := binary.BigEndian.Uint16(header[:])
pLength := binary.BigEndian.Uint32(header[2:])
pLengthInt := int(pLength)
if pLengthInt > c.MaximumPacketBytes {
return 0, nil, errors.New("gumble: packet larger than maximum allowed size")
}
if pLengthInt > len(c.buffer) {
c.buffer = make([]byte, pLengthInt)
}
if _, err := io.ReadFull(c.Conn, c.buffer[:pLengthInt]); err != nil {
return 0, nil, err
}
return pType, c.buffer[:pLengthInt], nil
} | go | func (c *Conn) ReadPacket() (uint16, []byte, error) {
c.Conn.SetReadDeadline(time.Now().Add(c.Timeout))
var header [6]byte
if _, err := io.ReadFull(c.Conn, header[:]); err != nil {
return 0, nil, err
}
pType := binary.BigEndian.Uint16(header[:])
pLength := binary.BigEndian.Uint32(header[2:])
pLengthInt := int(pLength)
if pLengthInt > c.MaximumPacketBytes {
return 0, nil, errors.New("gumble: packet larger than maximum allowed size")
}
if pLengthInt > len(c.buffer) {
c.buffer = make([]byte, pLengthInt)
}
if _, err := io.ReadFull(c.Conn, c.buffer[:pLengthInt]); err != nil {
return 0, nil, err
}
return pType, c.buffer[:pLengthInt], nil
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"ReadPacket",
"(",
")",
"(",
"uint16",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"c",
".",
"Conn",
".",
"SetReadDeadline",
"(",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"c",
".",
"Timeout",
")",
... | // ReadPacket reads a packet from the server. Returns the packet type, the
// packet data, and nil on success.
//
// This function should only be called by a single go routine. | [
"ReadPacket",
"reads",
"a",
"packet",
"from",
"the",
"server",
".",
"Returns",
"the",
"packet",
"type",
"the",
"packet",
"data",
"and",
"nil",
"on",
"success",
".",
"This",
"function",
"should",
"only",
"be",
"called",
"by",
"a",
"single",
"go",
"routine",... | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/conn.go#L43-L62 |
151,019 | layeh/gumble | gumble/conn.go | WriteAudio | func (c *Conn) WriteAudio(format, target byte, sequence int64, final bool, data []byte, X, Y, Z *float32) error {
var buff [1 + varint.MaxVarintLen*2]byte
buff[0] = (format << 5) | target
n := varint.Encode(buff[1:], sequence)
if n == 0 {
return errors.New("gumble: varint out of range")
}
l := int64(len(data))
if final {
l |= 0x2000
}
m := varint.Encode(buff[1+n:], l)
if m == 0 {
return errors.New("gumble: varint out of range")
}
header := buff[:1+n+m]
var positionalLength int
if X != nil {
positionalLength = 3 * 4
}
c.Lock()
defer c.Unlock()
if err := c.writeHeader(1, uint32(len(header)+len(data)+positionalLength)); err != nil {
return err
}
if _, err := c.Conn.Write(header); err != nil {
return err
}
if _, err := c.Conn.Write(data); err != nil {
return err
}
if positionalLength > 0 {
if err := binary.Write(c.Conn, binary.LittleEndian, *X); err != nil {
return err
}
if err := binary.Write(c.Conn, binary.LittleEndian, *Y); err != nil {
return err
}
if err := binary.Write(c.Conn, binary.LittleEndian, *Z); err != nil {
return err
}
}
return nil
} | go | func (c *Conn) WriteAudio(format, target byte, sequence int64, final bool, data []byte, X, Y, Z *float32) error {
var buff [1 + varint.MaxVarintLen*2]byte
buff[0] = (format << 5) | target
n := varint.Encode(buff[1:], sequence)
if n == 0 {
return errors.New("gumble: varint out of range")
}
l := int64(len(data))
if final {
l |= 0x2000
}
m := varint.Encode(buff[1+n:], l)
if m == 0 {
return errors.New("gumble: varint out of range")
}
header := buff[:1+n+m]
var positionalLength int
if X != nil {
positionalLength = 3 * 4
}
c.Lock()
defer c.Unlock()
if err := c.writeHeader(1, uint32(len(header)+len(data)+positionalLength)); err != nil {
return err
}
if _, err := c.Conn.Write(header); err != nil {
return err
}
if _, err := c.Conn.Write(data); err != nil {
return err
}
if positionalLength > 0 {
if err := binary.Write(c.Conn, binary.LittleEndian, *X); err != nil {
return err
}
if err := binary.Write(c.Conn, binary.LittleEndian, *Y); err != nil {
return err
}
if err := binary.Write(c.Conn, binary.LittleEndian, *Z); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"WriteAudio",
"(",
"format",
",",
"target",
"byte",
",",
"sequence",
"int64",
",",
"final",
"bool",
",",
"data",
"[",
"]",
"byte",
",",
"X",
",",
"Y",
",",
"Z",
"*",
"float32",
")",
"error",
"{",
"var",
"buff",... | // WriteAudio writes an audio packet to the connection. | [
"WriteAudio",
"writes",
"an",
"audio",
"packet",
"to",
"the",
"connection",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/conn.go#L65-L113 |
151,020 | layeh/gumble | gumble/conn.go | WritePacket | func (c *Conn) WritePacket(ptype uint16, data []byte) error {
c.Lock()
defer c.Unlock()
if err := c.writeHeader(uint16(ptype), uint32(len(data))); err != nil {
return err
}
if _, err := c.Conn.Write(data); err != nil {
return err
}
return nil
} | go | func (c *Conn) WritePacket(ptype uint16, data []byte) error {
c.Lock()
defer c.Unlock()
if err := c.writeHeader(uint16(ptype), uint32(len(data))); err != nil {
return err
}
if _, err := c.Conn.Write(data); err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"WritePacket",
"(",
"ptype",
"uint16",
",",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"c",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"Unlock",
"(",
")",
"\n",
"if",
"err",
":=",
"c",
".",
"writeHeade... | // WritePacket writes a data packet of the given type to the connection. | [
"WritePacket",
"writes",
"a",
"data",
"packet",
"of",
"the",
"given",
"type",
"to",
"the",
"connection",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/conn.go#L116-L126 |
151,021 | layeh/gumble | gumble/conn.go | WriteProto | func (c *Conn) WriteProto(message proto.Message) error {
var protoType uint16
switch message.(type) {
case *MumbleProto.Version:
protoType = 0
case *MumbleProto.Authenticate:
protoType = 2
case *MumbleProto.Ping:
protoType = 3
case *MumbleProto.Reject:
protoType = 4
case *MumbleProto.ServerSync:
protoType = 5
case *MumbleProto.ChannelRemove:
protoType = 6
case *MumbleProto.ChannelState:
protoType = 7
case *MumbleProto.UserRemove:
protoType = 8
case *MumbleProto.UserState:
protoType = 9
case *MumbleProto.BanList:
protoType = 10
case *MumbleProto.TextMessage:
protoType = 11
case *MumbleProto.PermissionDenied:
protoType = 12
case *MumbleProto.ACL:
protoType = 13
case *MumbleProto.QueryUsers:
protoType = 14
case *MumbleProto.CryptSetup:
protoType = 15
case *MumbleProto.ContextActionModify:
protoType = 16
case *MumbleProto.ContextAction:
protoType = 17
case *MumbleProto.UserList:
protoType = 18
case *MumbleProto.VoiceTarget:
protoType = 19
case *MumbleProto.PermissionQuery:
protoType = 20
case *MumbleProto.CodecVersion:
protoType = 21
case *MumbleProto.UserStats:
protoType = 22
case *MumbleProto.RequestBlob:
protoType = 23
case *MumbleProto.ServerConfig:
protoType = 24
case *MumbleProto.SuggestConfig:
protoType = 25
default:
return errors.New("gumble: unknown message type")
}
data, err := proto.Marshal(message)
if err != nil {
return err
}
return c.WritePacket(protoType, data)
} | go | func (c *Conn) WriteProto(message proto.Message) error {
var protoType uint16
switch message.(type) {
case *MumbleProto.Version:
protoType = 0
case *MumbleProto.Authenticate:
protoType = 2
case *MumbleProto.Ping:
protoType = 3
case *MumbleProto.Reject:
protoType = 4
case *MumbleProto.ServerSync:
protoType = 5
case *MumbleProto.ChannelRemove:
protoType = 6
case *MumbleProto.ChannelState:
protoType = 7
case *MumbleProto.UserRemove:
protoType = 8
case *MumbleProto.UserState:
protoType = 9
case *MumbleProto.BanList:
protoType = 10
case *MumbleProto.TextMessage:
protoType = 11
case *MumbleProto.PermissionDenied:
protoType = 12
case *MumbleProto.ACL:
protoType = 13
case *MumbleProto.QueryUsers:
protoType = 14
case *MumbleProto.CryptSetup:
protoType = 15
case *MumbleProto.ContextActionModify:
protoType = 16
case *MumbleProto.ContextAction:
protoType = 17
case *MumbleProto.UserList:
protoType = 18
case *MumbleProto.VoiceTarget:
protoType = 19
case *MumbleProto.PermissionQuery:
protoType = 20
case *MumbleProto.CodecVersion:
protoType = 21
case *MumbleProto.UserStats:
protoType = 22
case *MumbleProto.RequestBlob:
protoType = 23
case *MumbleProto.ServerConfig:
protoType = 24
case *MumbleProto.SuggestConfig:
protoType = 25
default:
return errors.New("gumble: unknown message type")
}
data, err := proto.Marshal(message)
if err != nil {
return err
}
return c.WritePacket(protoType, data)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"WriteProto",
"(",
"message",
"proto",
".",
"Message",
")",
"error",
"{",
"var",
"protoType",
"uint16",
"\n",
"switch",
"message",
".",
"(",
"type",
")",
"{",
"case",
"*",
"MumbleProto",
".",
"Version",
":",
"protoTy... | // WriteProto writes a protocol buffer message to the connection. | [
"WriteProto",
"writes",
"a",
"protocol",
"buffer",
"message",
"to",
"the",
"connection",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/conn.go#L139-L200 |
151,022 | layeh/gumble | gumbleutil/channel.go | ChannelPath | func ChannelPath(channel *gumble.Channel) []string {
var pieces []string
for ; channel != nil; channel = channel.Parent {
pieces = append(pieces, channel.Name)
}
for i := 0; i < (len(pieces) / 2); i++ {
pieces[len(pieces)-1-i], pieces[i] = pieces[i], pieces[len(pieces)-1-i]
}
return pieces
} | go | func ChannelPath(channel *gumble.Channel) []string {
var pieces []string
for ; channel != nil; channel = channel.Parent {
pieces = append(pieces, channel.Name)
}
for i := 0; i < (len(pieces) / 2); i++ {
pieces[len(pieces)-1-i], pieces[i] = pieces[i], pieces[len(pieces)-1-i]
}
return pieces
} | [
"func",
"ChannelPath",
"(",
"channel",
"*",
"gumble",
".",
"Channel",
")",
"[",
"]",
"string",
"{",
"var",
"pieces",
"[",
"]",
"string",
"\n",
"for",
";",
"channel",
"!=",
"nil",
";",
"channel",
"=",
"channel",
".",
"Parent",
"{",
"pieces",
"=",
"app... | // ChannelPath returns a slice of channel names, starting from the root channel
// to the given channel. | [
"ChannelPath",
"returns",
"a",
"slice",
"of",
"channel",
"names",
"starting",
"from",
"the",
"root",
"channel",
"to",
"the",
"given",
"channel",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleutil/channel.go#L9-L18 |
151,023 | layeh/gumble | gumble/config.go | Attach | func (c *Config) Attach(l EventListener) Detacher {
return c.Listeners.Attach(l)
} | go | func (c *Config) Attach(l EventListener) Detacher {
return c.Listeners.Attach(l)
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"Attach",
"(",
"l",
"EventListener",
")",
"Detacher",
"{",
"return",
"c",
".",
"Listeners",
".",
"Attach",
"(",
"l",
")",
"\n",
"}"
] | // Attach is an alias of c.Listeners.Attach. | [
"Attach",
"is",
"an",
"alias",
"of",
"c",
".",
"Listeners",
".",
"Attach",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/config.go#L40-L42 |
151,024 | layeh/gumble | gumble/config.go | AttachAudio | func (c *Config) AttachAudio(l AudioListener) Detacher {
return c.AudioListeners.Attach(l)
} | go | func (c *Config) AttachAudio(l AudioListener) Detacher {
return c.AudioListeners.Attach(l)
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"AttachAudio",
"(",
"l",
"AudioListener",
")",
"Detacher",
"{",
"return",
"c",
".",
"AudioListeners",
".",
"Attach",
"(",
"l",
")",
"\n",
"}"
] | // AttachAudio is an alias of c.AudioListeners.Attach. | [
"AttachAudio",
"is",
"an",
"alias",
"of",
"c",
".",
"AudioListeners",
".",
"Attach",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/config.go#L45-L47 |
151,025 | layeh/gumble | gumble/channels.go | create | func (c Channels) create(id uint32) *Channel {
channel := &Channel{
ID: id,
Links: Channels{},
Children: Channels{},
Users: Users{},
}
c[id] = channel
return channel
} | go | func (c Channels) create(id uint32) *Channel {
channel := &Channel{
ID: id,
Links: Channels{},
Children: Channels{},
Users: Users{},
}
c[id] = channel
return channel
} | [
"func",
"(",
"c",
"Channels",
")",
"create",
"(",
"id",
"uint32",
")",
"*",
"Channel",
"{",
"channel",
":=",
"&",
"Channel",
"{",
"ID",
":",
"id",
",",
"Links",
":",
"Channels",
"{",
"}",
",",
"Children",
":",
"Channels",
"{",
"}",
",",
"Users",
... | // create adds a new channel with the given id to the collection. If a channel
// with the given id already exists, it is overwritten. | [
"create",
"adds",
"a",
"new",
"channel",
"with",
"the",
"given",
"id",
"to",
"the",
"collection",
".",
"If",
"a",
"channel",
"with",
"the",
"given",
"id",
"already",
"exists",
"it",
"is",
"overwritten",
"."
] | 1ea1159c495624266a4adea43580748fd0fc9c57 | https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/channels.go#L8-L17 |
151,026 | mileusna/useragent | ua.go | findBestMatch | func (p properties) findBestMatch(withVerOnly bool) string {
n := 2
if withVerOnly {
n = 1
}
for i := 0; i < n; i++ {
for k, v := range p {
switch k {
case Chrome, Firefox, Safari, "Version", "Mobile", "Mobile Safari", "Mozilla", "AppleWebKit", "Windows NT", "Windows Phone OS", Android, "Macintosh", Linux, "GSA":
default:
if i == 0 {
if v != "" { // in first check, only return keys with value
return k
}
} else {
return k
}
}
}
}
return ""
} | go | func (p properties) findBestMatch(withVerOnly bool) string {
n := 2
if withVerOnly {
n = 1
}
for i := 0; i < n; i++ {
for k, v := range p {
switch k {
case Chrome, Firefox, Safari, "Version", "Mobile", "Mobile Safari", "Mozilla", "AppleWebKit", "Windows NT", "Windows Phone OS", Android, "Macintosh", Linux, "GSA":
default:
if i == 0 {
if v != "" { // in first check, only return keys with value
return k
}
} else {
return k
}
}
}
}
return ""
} | [
"func",
"(",
"p",
"properties",
")",
"findBestMatch",
"(",
"withVerOnly",
"bool",
")",
"string",
"{",
"n",
":=",
"2",
"\n",
"if",
"withVerOnly",
"{",
"n",
"=",
"1",
"\n",
"}",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
"{"... | // findBestMatch from the rest of the bunch
// in first cycle only return key vith version value
// if withVerValue is false, do another cycle and return any token | [
"findBestMatch",
"from",
"the",
"rest",
"of",
"the",
"bunch",
"in",
"first",
"cycle",
"only",
"return",
"key",
"vith",
"version",
"value",
"if",
"withVerValue",
"is",
"false",
"do",
"another",
"cycle",
"and",
"return",
"any",
"token"
] | 3e331f0949a545b6362f47a5beca8b0370a098a1 | https://github.com/mileusna/useragent/blob/3e331f0949a545b6362f47a5beca8b0370a098a1/ua.go#L386-L407 |
151,027 | webx-top/echo | middleware/proxy.go | proxyHTTPWithFlushInterval | func proxyHTTPWithFlushInterval(t *ProxyTarget) http.Handler {
proxy := httputil.NewSingleHostReverseProxy(t.URL)
proxy.FlushInterval = t.FlushInterval
return proxy
} | go | func proxyHTTPWithFlushInterval(t *ProxyTarget) http.Handler {
proxy := httputil.NewSingleHostReverseProxy(t.URL)
proxy.FlushInterval = t.FlushInterval
return proxy
} | [
"func",
"proxyHTTPWithFlushInterval",
"(",
"t",
"*",
"ProxyTarget",
")",
"http",
".",
"Handler",
"{",
"proxy",
":=",
"httputil",
".",
"NewSingleHostReverseProxy",
"(",
"t",
".",
"URL",
")",
"\n",
"proxy",
".",
"FlushInterval",
"=",
"t",
".",
"FlushInterval",
... | // Server-Sent Events | [
"Server",
"-",
"Sent",
"Events"
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/proxy.go#L99-L103 |
151,028 | webx-top/echo | middleware/proxy.go | Proxy | func Proxy(balancer ProxyBalancer) echo.MiddlewareFuncd {
c := DefaultProxyConfig
c.Balancer = balancer
return ProxyWithConfig(c)
} | go | func Proxy(balancer ProxyBalancer) echo.MiddlewareFuncd {
c := DefaultProxyConfig
c.Balancer = balancer
return ProxyWithConfig(c)
} | [
"func",
"Proxy",
"(",
"balancer",
"ProxyBalancer",
")",
"echo",
".",
"MiddlewareFuncd",
"{",
"c",
":=",
"DefaultProxyConfig",
"\n",
"c",
".",
"Balancer",
"=",
"balancer",
"\n",
"return",
"ProxyWithConfig",
"(",
"c",
")",
"\n",
"}"
] | // Proxy returns a Proxy middleware.
//
// Proxy middleware forwards the request to upstream server using a configured load balancing technique. | [
"Proxy",
"returns",
"a",
"Proxy",
"middleware",
".",
"Proxy",
"middleware",
"forwards",
"the",
"request",
"to",
"upstream",
"server",
"using",
"a",
"configured",
"load",
"balancing",
"technique",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/proxy.go#L217-L221 |
151,029 | webx-top/echo | middleware/limit.go | MaxAllowed | func MaxAllowed(n int) echo.MiddlewareFunc {
sem := make(chan struct{}, n)
acquire := func() { sem <- struct{}{} }
release := func() { <-sem }
return func(h echo.Handler) echo.Handler {
return echo.HandlerFunc(func(c echo.Context) error {
acquire() // before request
err := h.Handle(c)
release() // after request
return err
})
}
} | go | func MaxAllowed(n int) echo.MiddlewareFunc {
sem := make(chan struct{}, n)
acquire := func() { sem <- struct{}{} }
release := func() { <-sem }
return func(h echo.Handler) echo.Handler {
return echo.HandlerFunc(func(c echo.Context) error {
acquire() // before request
err := h.Handle(c)
release() // after request
return err
})
}
} | [
"func",
"MaxAllowed",
"(",
"n",
"int",
")",
"echo",
".",
"MiddlewareFunc",
"{",
"sem",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
",",
"n",
")",
"\n",
"acquire",
":=",
"func",
"(",
")",
"{",
"sem",
"<-",
"struct",
"{",
"}",
"{",
"}",
"}",
"... | // MaxAllowed limits simultaneous requests; can help with high traffic load | [
"MaxAllowed",
"limits",
"simultaneous",
"requests",
";",
"can",
"help",
"with",
"high",
"traffic",
"load"
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/limit.go#L8-L20 |
151,030 | webx-top/echo | engine/engine.go | ServeHTTP | func (h HandlerFunc) ServeHTTP(req Request, res Response) {
h(req, res)
} | go | func (h HandlerFunc) ServeHTTP(req Request, res Response) {
h(req, res)
} | [
"func",
"(",
"h",
"HandlerFunc",
")",
"ServeHTTP",
"(",
"req",
"Request",
",",
"res",
"Response",
")",
"{",
"h",
"(",
"req",
",",
"res",
")",
"\n",
"}"
] | // ServeHTTP serves HTTP request. | [
"ServeHTTP",
"serves",
"HTTP",
"request",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/engine/engine.go#L198-L200 |
151,031 | webx-top/echo | context_x_response.go | HTML | func (c *xContext) HTML(html string, codes ...int) (err error) {
c.response.Header().Set(HeaderContentType, MIMETextHTMLCharsetUTF8)
err = c.Blob([]byte(html), codes...)
return
} | go | func (c *xContext) HTML(html string, codes ...int) (err error) {
c.response.Header().Set(HeaderContentType, MIMETextHTMLCharsetUTF8)
err = c.Blob([]byte(html), codes...)
return
} | [
"func",
"(",
"c",
"*",
"xContext",
")",
"HTML",
"(",
"html",
"string",
",",
"codes",
"...",
"int",
")",
"(",
"err",
"error",
")",
"{",
"c",
".",
"response",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"HeaderContentType",
",",
"MIMETextHTMLCharsetUTF8",
... | // HTML sends an HTTP response with status code. | [
"HTML",
"sends",
"an",
"HTTP",
"response",
"with",
"status",
"code",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/context_x_response.go#L57-L61 |
151,032 | webx-top/echo | context_x_response.go | String | func (c *xContext) String(s string, codes ...int) (err error) {
c.response.Header().Set(HeaderContentType, MIMETextPlainCharsetUTF8)
err = c.Blob([]byte(s), codes...)
return
} | go | func (c *xContext) String(s string, codes ...int) (err error) {
c.response.Header().Set(HeaderContentType, MIMETextPlainCharsetUTF8)
err = c.Blob([]byte(s), codes...)
return
} | [
"func",
"(",
"c",
"*",
"xContext",
")",
"String",
"(",
"s",
"string",
",",
"codes",
"...",
"int",
")",
"(",
"err",
"error",
")",
"{",
"c",
".",
"response",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"HeaderContentType",
",",
"MIMETextPlainCharsetUTF8",
... | // String sends a string response with status code. | [
"String",
"sends",
"a",
"string",
"response",
"with",
"status",
"code",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/context_x_response.go#L64-L68 |
151,033 | webx-top/echo | context_x_response.go | JSON | func (c *xContext) JSON(i interface{}, codes ...int) (err error) {
var b []byte
if c.echo.Debug() {
b, err = json.MarshalIndent(i, "", " ")
} else {
b, err = json.Marshal(i)
}
if err != nil {
return err
}
return c.JSONBlob(b, codes...)
} | go | func (c *xContext) JSON(i interface{}, codes ...int) (err error) {
var b []byte
if c.echo.Debug() {
b, err = json.MarshalIndent(i, "", " ")
} else {
b, err = json.Marshal(i)
}
if err != nil {
return err
}
return c.JSONBlob(b, codes...)
} | [
"func",
"(",
"c",
"*",
"xContext",
")",
"JSON",
"(",
"i",
"interface",
"{",
"}",
",",
"codes",
"...",
"int",
")",
"(",
"err",
"error",
")",
"{",
"var",
"b",
"[",
"]",
"byte",
"\n",
"if",
"c",
".",
"echo",
".",
"Debug",
"(",
")",
"{",
"b",
"... | // JSON sends a JSON response with status code. | [
"JSON",
"sends",
"a",
"JSON",
"response",
"with",
"status",
"code",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/context_x_response.go#L87-L98 |
151,034 | webx-top/echo | context_x_response.go | JSONBlob | func (c *xContext) JSONBlob(b []byte, codes ...int) (err error) {
c.response.Header().Set(HeaderContentType, MIMEApplicationJSONCharsetUTF8)
err = c.Blob(b, codes...)
return
} | go | func (c *xContext) JSONBlob(b []byte, codes ...int) (err error) {
c.response.Header().Set(HeaderContentType, MIMEApplicationJSONCharsetUTF8)
err = c.Blob(b, codes...)
return
} | [
"func",
"(",
"c",
"*",
"xContext",
")",
"JSONBlob",
"(",
"b",
"[",
"]",
"byte",
",",
"codes",
"...",
"int",
")",
"(",
"err",
"error",
")",
"{",
"c",
".",
"response",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"HeaderContentType",
",",
"MIMEApplicati... | // JSONBlob sends a JSON blob response with status code. | [
"JSONBlob",
"sends",
"a",
"JSON",
"blob",
"response",
"with",
"status",
"code",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/context_x_response.go#L101-L105 |
151,035 | webx-top/echo | context_x_response.go | JSONP | func (c *xContext) JSONP(callback string, i interface{}, codes ...int) (err error) {
b, err := json.Marshal(i)
if err != nil {
return err
}
c.response.Header().Set(HeaderContentType, MIMEApplicationJavaScriptCharsetUTF8)
b = []byte(callback + "(" + string(b) + ");")
err = c.Blob(b, codes...)
return
} | go | func (c *xContext) JSONP(callback string, i interface{}, codes ...int) (err error) {
b, err := json.Marshal(i)
if err != nil {
return err
}
c.response.Header().Set(HeaderContentType, MIMEApplicationJavaScriptCharsetUTF8)
b = []byte(callback + "(" + string(b) + ");")
err = c.Blob(b, codes...)
return
} | [
"func",
"(",
"c",
"*",
"xContext",
")",
"JSONP",
"(",
"callback",
"string",
",",
"i",
"interface",
"{",
"}",
",",
"codes",
"...",
"int",
")",
"(",
"err",
"error",
")",
"{",
"b",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"i",
")",
"\n",
"if... | // JSONP sends a JSONP response with status code. It uses `callback` to construct
// the JSONP payload. | [
"JSONP",
"sends",
"a",
"JSONP",
"response",
"with",
"status",
"code",
".",
"It",
"uses",
"callback",
"to",
"construct",
"the",
"JSONP",
"payload",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/context_x_response.go#L109-L118 |
151,036 | webx-top/echo | context_x_response.go | XML | func (c *xContext) XML(i interface{}, codes ...int) (err error) {
var b []byte
if c.echo.Debug() {
b, err = xml.MarshalIndent(i, "", " ")
} else {
b, err = xml.Marshal(i)
}
if err != nil {
return err
}
return c.XMLBlob(b, codes...)
} | go | func (c *xContext) XML(i interface{}, codes ...int) (err error) {
var b []byte
if c.echo.Debug() {
b, err = xml.MarshalIndent(i, "", " ")
} else {
b, err = xml.Marshal(i)
}
if err != nil {
return err
}
return c.XMLBlob(b, codes...)
} | [
"func",
"(",
"c",
"*",
"xContext",
")",
"XML",
"(",
"i",
"interface",
"{",
"}",
",",
"codes",
"...",
"int",
")",
"(",
"err",
"error",
")",
"{",
"var",
"b",
"[",
"]",
"byte",
"\n",
"if",
"c",
".",
"echo",
".",
"Debug",
"(",
")",
"{",
"b",
",... | // XML sends an XML response with status code. | [
"XML",
"sends",
"an",
"XML",
"response",
"with",
"status",
"code",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/context_x_response.go#L121-L132 |
151,037 | webx-top/echo | context_x_response.go | XMLBlob | func (c *xContext) XMLBlob(b []byte, codes ...int) (err error) {
c.response.Header().Set(HeaderContentType, MIMEApplicationXMLCharsetUTF8)
b = []byte(xml.Header + string(b))
err = c.Blob(b, codes...)
return
} | go | func (c *xContext) XMLBlob(b []byte, codes ...int) (err error) {
c.response.Header().Set(HeaderContentType, MIMEApplicationXMLCharsetUTF8)
b = []byte(xml.Header + string(b))
err = c.Blob(b, codes...)
return
} | [
"func",
"(",
"c",
"*",
"xContext",
")",
"XMLBlob",
"(",
"b",
"[",
"]",
"byte",
",",
"codes",
"...",
"int",
")",
"(",
"err",
"error",
")",
"{",
"c",
".",
"response",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"HeaderContentType",
",",
"MIMEApplicatio... | // XMLBlob sends a XML blob response with status code. | [
"XMLBlob",
"sends",
"a",
"XML",
"blob",
"response",
"with",
"status",
"code",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/context_x_response.go#L135-L140 |
151,038 | webx-top/echo | context_x_response.go | NoContent | func (c *xContext) NoContent(codes ...int) error {
if len(codes) > 0 {
c.code = codes[0]
}
if c.code == 0 {
c.code = http.StatusOK
}
c.response.WriteHeader(c.code)
return nil
} | go | func (c *xContext) NoContent(codes ...int) error {
if len(codes) > 0 {
c.code = codes[0]
}
if c.code == 0 {
c.code = http.StatusOK
}
c.response.WriteHeader(c.code)
return nil
} | [
"func",
"(",
"c",
"*",
"xContext",
")",
"NoContent",
"(",
"codes",
"...",
"int",
")",
"error",
"{",
"if",
"len",
"(",
"codes",
")",
">",
"0",
"{",
"c",
".",
"code",
"=",
"codes",
"[",
"0",
"]",
"\n",
"}",
"\n",
"if",
"c",
".",
"code",
"==",
... | // NoContent sends a response with no body and a status code. | [
"NoContent",
"sends",
"a",
"response",
"with",
"no",
"body",
"and",
"a",
"status",
"code",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/context_x_response.go#L224-L233 |
151,039 | webx-top/echo | context_x_response.go | Redirect | func (c *xContext) Redirect(url string, codes ...int) error {
code := http.StatusFound
if len(codes) > 0 {
code = codes[0]
}
if code < http.StatusMultipleChoices || code > http.StatusTemporaryRedirect {
return ErrInvalidRedirectCode
}
err := c.preResponse()
if err != nil {
return err
}
format := c.Format()
if format != `html` && c.auto {
if render, ok := c.echo.formatRenderers[format]; ok && render != nil {
if c.dataEngine.GetData() == nil {
c.Set(`Location`, url)
c.dataEngine.SetData(c.Stored(), c.dataEngine.GetCode().Int())
} else {
c.dataEngine.SetURL(url)
}
return render(c, c.dataEngine.GetData())
}
}
c.response.Redirect(url, code)
return nil
} | go | func (c *xContext) Redirect(url string, codes ...int) error {
code := http.StatusFound
if len(codes) > 0 {
code = codes[0]
}
if code < http.StatusMultipleChoices || code > http.StatusTemporaryRedirect {
return ErrInvalidRedirectCode
}
err := c.preResponse()
if err != nil {
return err
}
format := c.Format()
if format != `html` && c.auto {
if render, ok := c.echo.formatRenderers[format]; ok && render != nil {
if c.dataEngine.GetData() == nil {
c.Set(`Location`, url)
c.dataEngine.SetData(c.Stored(), c.dataEngine.GetCode().Int())
} else {
c.dataEngine.SetURL(url)
}
return render(c, c.dataEngine.GetData())
}
}
c.response.Redirect(url, code)
return nil
} | [
"func",
"(",
"c",
"*",
"xContext",
")",
"Redirect",
"(",
"url",
"string",
",",
"codes",
"...",
"int",
")",
"error",
"{",
"code",
":=",
"http",
".",
"StatusFound",
"\n",
"if",
"len",
"(",
"codes",
")",
">",
"0",
"{",
"code",
"=",
"codes",
"[",
"0"... | // Redirect redirects the request with status code. | [
"Redirect",
"redirects",
"the",
"request",
"with",
"status",
"code",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/context_x_response.go#L236-L262 |
151,040 | webx-top/echo | wrapper.go | WrapMiddlewareFromHandler | func WrapMiddlewareFromHandler(h HandlerFunc) Middleware {
return MiddlewareFunc(func(next Handler) Handler {
return HandlerFunc(func(c Context) error {
if err := h.Handle(c); err != nil {
return err
}
return next.Handle(c)
})
})
} | go | func WrapMiddlewareFromHandler(h HandlerFunc) Middleware {
return MiddlewareFunc(func(next Handler) Handler {
return HandlerFunc(func(c Context) error {
if err := h.Handle(c); err != nil {
return err
}
return next.Handle(c)
})
})
} | [
"func",
"WrapMiddlewareFromHandler",
"(",
"h",
"HandlerFunc",
")",
"Middleware",
"{",
"return",
"MiddlewareFunc",
"(",
"func",
"(",
"next",
"Handler",
")",
"Handler",
"{",
"return",
"HandlerFunc",
"(",
"func",
"(",
"c",
"Context",
")",
"error",
"{",
"if",
"e... | // WrapMiddlewareFromHandler wrap `echo.HandlerFunc` into `echo.Middleware`. | [
"WrapMiddlewareFromHandler",
"wrap",
"echo",
".",
"HandlerFunc",
"into",
"echo",
".",
"Middleware",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/wrapper.go#L108-L117 |
151,041 | webx-top/echo | wrapper.go | WrapMiddlewareFromStdHandler | func WrapMiddlewareFromStdHandler(h http.Handler) Middleware {
return MiddlewareFunc(func(next Handler) Handler {
return HandlerFunc(func(c Context) error {
h.ServeHTTP(c.Response().StdResponseWriter(), c.Request().StdRequest())
if c.Response().Committed() {
return nil
}
return next.Handle(c)
})
})
} | go | func WrapMiddlewareFromStdHandler(h http.Handler) Middleware {
return MiddlewareFunc(func(next Handler) Handler {
return HandlerFunc(func(c Context) error {
h.ServeHTTP(c.Response().StdResponseWriter(), c.Request().StdRequest())
if c.Response().Committed() {
return nil
}
return next.Handle(c)
})
})
} | [
"func",
"WrapMiddlewareFromStdHandler",
"(",
"h",
"http",
".",
"Handler",
")",
"Middleware",
"{",
"return",
"MiddlewareFunc",
"(",
"func",
"(",
"next",
"Handler",
")",
"Handler",
"{",
"return",
"HandlerFunc",
"(",
"func",
"(",
"c",
"Context",
")",
"error",
"... | // WrapMiddlewareFromStdHandler wrap `http.HandlerFunc` into `echo.Middleware`. | [
"WrapMiddlewareFromStdHandler",
"wrap",
"http",
".",
"HandlerFunc",
"into",
"echo",
".",
"Middleware",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/wrapper.go#L120-L130 |
151,042 | webx-top/echo | middleware/session/engine/cookie/helper.go | KeyPairs | func KeyPairs(keys ...string) [][]byte {
var hashKey, blockKey string
if len(keys) > 0 {
hashKey = keys[0]
}
if len(keys) > 1 {
blockKey = keys[1]
}
keyPairs := [][]byte{}
if len(hashKey) > 0 {
keyPairs = append(keyPairs, []byte(hashKey))
if len(blockKey) > 0 && blockKey != hashKey {
keyPairs = append(keyPairs, []byte(blockKey))
}
}
return keyPairs
} | go | func KeyPairs(keys ...string) [][]byte {
var hashKey, blockKey string
if len(keys) > 0 {
hashKey = keys[0]
}
if len(keys) > 1 {
blockKey = keys[1]
}
keyPairs := [][]byte{}
if len(hashKey) > 0 {
keyPairs = append(keyPairs, []byte(hashKey))
if len(blockKey) > 0 && blockKey != hashKey {
keyPairs = append(keyPairs, []byte(blockKey))
}
}
return keyPairs
} | [
"func",
"KeyPairs",
"(",
"keys",
"...",
"string",
")",
"[",
"]",
"[",
"]",
"byte",
"{",
"var",
"hashKey",
",",
"blockKey",
"string",
"\n",
"if",
"len",
"(",
"keys",
")",
">",
"0",
"{",
"hashKey",
"=",
"keys",
"[",
"0",
"]",
"\n",
"}",
"\n",
"if... | // KeyPairs Convert hashKey and blockKey to bytes
// @param hashKey
// @param blockKey | [
"KeyPairs",
"Convert",
"hashKey",
"and",
"blockKey",
"to",
"bytes"
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/session/engine/cookie/helper.go#L6-L23 |
151,043 | webx-top/echo | middleware/session/engine/mysql/mysql.go | NewMySQLStore | func NewMySQLStore(endpoint string, tableName string, keyPairs ...[]byte) (*MySQLStore, error) {
db, err := sql.Open("mysql", endpoint)
if err != nil {
return nil, err
}
return NewMySQLStoreFromConnection(db, tableName, keyPairs...)
} | go | func NewMySQLStore(endpoint string, tableName string, keyPairs ...[]byte) (*MySQLStore, error) {
db, err := sql.Open("mysql", endpoint)
if err != nil {
return nil, err
}
return NewMySQLStoreFromConnection(db, tableName, keyPairs...)
} | [
"func",
"NewMySQLStore",
"(",
"endpoint",
"string",
",",
"tableName",
"string",
",",
"keyPairs",
"...",
"[",
"]",
"byte",
")",
"(",
"*",
"MySQLStore",
",",
"error",
")",
"{",
"db",
",",
"err",
":=",
"sql",
".",
"Open",
"(",
"\"",
"\"",
",",
"endpoint... | // NewMySQLStore takes the following paramaters
// endpoint - A sql.Open style endpoint
// tableName - table where sessions are to be saved. Required fields are created automatically if the table doesnot exist.
// path - path for Set-Cookie header
// maxAge
// codecs | [
"NewMySQLStore",
"takes",
"the",
"following",
"paramaters",
"endpoint",
"-",
"A",
"sql",
".",
"Open",
"style",
"endpoint",
"tableName",
"-",
"table",
"where",
"sessions",
"are",
"to",
"be",
"saved",
".",
"Required",
"fields",
"are",
"created",
"automatically",
... | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/session/engine/mysql/mysql.go#L91-L98 |
151,044 | webx-top/echo | helper.go | HandlerName | func HandlerName(h interface{}) string {
v := reflect.ValueOf(h)
t := v.Type()
if t.Kind() == reflect.Func {
return runtime.FuncForPC(v.Pointer()).Name()
}
return t.String()
} | go | func HandlerName(h interface{}) string {
v := reflect.ValueOf(h)
t := v.Type()
if t.Kind() == reflect.Func {
return runtime.FuncForPC(v.Pointer()).Name()
}
return t.String()
} | [
"func",
"HandlerName",
"(",
"h",
"interface",
"{",
"}",
")",
"string",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"h",
")",
"\n",
"t",
":=",
"v",
".",
"Type",
"(",
")",
"\n",
"if",
"t",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Func",
... | // HandlerName returns the handler name | [
"HandlerName",
"returns",
"the",
"handler",
"name"
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/helper.go#L15-L22 |
151,045 | webx-top/echo | helper.go | HandlerPath | func HandlerPath(h interface{}) string {
v := reflect.ValueOf(h)
t := v.Type()
switch t.Kind() {
case reflect.Func:
return runtime.FuncForPC(v.Pointer()).Name()
case reflect.Ptr:
t = t.Elem()
fallthrough
case reflect.Struct:
return t.PkgPath() + `.` + t.Name()
}
return ``
} | go | func HandlerPath(h interface{}) string {
v := reflect.ValueOf(h)
t := v.Type()
switch t.Kind() {
case reflect.Func:
return runtime.FuncForPC(v.Pointer()).Name()
case reflect.Ptr:
t = t.Elem()
fallthrough
case reflect.Struct:
return t.PkgPath() + `.` + t.Name()
}
return ``
} | [
"func",
"HandlerPath",
"(",
"h",
"interface",
"{",
"}",
")",
"string",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"h",
")",
"\n",
"t",
":=",
"v",
".",
"Type",
"(",
")",
"\n",
"switch",
"t",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".... | // HandlerPath returns the handler path | [
"HandlerPath",
"returns",
"the",
"handler",
"path"
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/helper.go#L25-L38 |
151,046 | webx-top/echo | context_store.go | MarshalXML | func (s Store) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
if start.Name.Local == `Store` {
start.Name.Local = `Map`
}
if err := e.EncodeToken(start); err != nil {
return err
}
for key, value := range s {
elem := xml.StartElement{
Name: xml.Name{Space: ``, Local: key},
Attr: []xml.Attr{},
}
if err := e.EncodeElement(value, elem); err != nil {
return err
}
}
return e.EncodeToken(xml.EndElement{Name: start.Name})
} | go | func (s Store) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
if start.Name.Local == `Store` {
start.Name.Local = `Map`
}
if err := e.EncodeToken(start); err != nil {
return err
}
for key, value := range s {
elem := xml.StartElement{
Name: xml.Name{Space: ``, Local: key},
Attr: []xml.Attr{},
}
if err := e.EncodeElement(value, elem); err != nil {
return err
}
}
return e.EncodeToken(xml.EndElement{Name: start.Name})
} | [
"func",
"(",
"s",
"Store",
")",
"MarshalXML",
"(",
"e",
"*",
"xml",
".",
"Encoder",
",",
"start",
"xml",
".",
"StartElement",
")",
"error",
"{",
"if",
"start",
".",
"Name",
".",
"Local",
"==",
"`Store`",
"{",
"start",
".",
"Name",
".",
"Local",
"="... | // MarshalXML allows type Store to be used with xml.Marshal | [
"MarshalXML",
"allows",
"type",
"Store",
"to",
"be",
"used",
"with",
"xml",
".",
"Marshal"
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/context_store.go#L173-L190 |
151,047 | webx-top/echo | handler/mvc/module.go | SafelyCall | func (a *Module) SafelyCall(fn reflect.Value, args []reflect.Value) (resp []reflect.Value, err error) {
defer func() {
if e := recover(); e != nil {
resp = nil
panicErr := echo.NewPanicError(e, nil)
panicErr.SetDebug(a.Application.Core.Debug())
content := fmt.Sprintf(`Handler crashed with error: %v`, e)
for i := 1; ; i++ {
pc, file, line, ok := runtime.Caller(i)
if !ok {
break
}
t := &echo.Trace{
File: file,
Line: line,
Func: runtime.FuncForPC(pc).Name(),
}
panicErr.AddTrace(t)
content += "\n" + fmt.Sprintf(`%v:%v`, file, line)
}
panicErr.SetErrorString(content)
a.Application.Core.Logger().Error(panicErr)
err = panicErr
}
}()
if fn.Type().NumIn() > 0 {
return fn.Call(args), err
}
return fn.Call(nil), err
} | go | func (a *Module) SafelyCall(fn reflect.Value, args []reflect.Value) (resp []reflect.Value, err error) {
defer func() {
if e := recover(); e != nil {
resp = nil
panicErr := echo.NewPanicError(e, nil)
panicErr.SetDebug(a.Application.Core.Debug())
content := fmt.Sprintf(`Handler crashed with error: %v`, e)
for i := 1; ; i++ {
pc, file, line, ok := runtime.Caller(i)
if !ok {
break
}
t := &echo.Trace{
File: file,
Line: line,
Func: runtime.FuncForPC(pc).Name(),
}
panicErr.AddTrace(t)
content += "\n" + fmt.Sprintf(`%v:%v`, file, line)
}
panicErr.SetErrorString(content)
a.Application.Core.Logger().Error(panicErr)
err = panicErr
}
}()
if fn.Type().NumIn() > 0 {
return fn.Call(args), err
}
return fn.Call(nil), err
} | [
"func",
"(",
"a",
"*",
"Module",
")",
"SafelyCall",
"(",
"fn",
"reflect",
".",
"Value",
",",
"args",
"[",
"]",
"reflect",
".",
"Value",
")",
"(",
"resp",
"[",
"]",
"reflect",
".",
"Value",
",",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")",... | // SafelyCall invokes `function` in recover block | [
"SafelyCall",
"invokes",
"function",
"in",
"recover",
"block"
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/handler/mvc/module.go#L237-L266 |
151,048 | webx-top/echo | handler/oauth2/auth2.go | New | func New(hostURL string, cfg *Config) *OAuth {
c := DefaultConfig().MergeSingle(cfg)
c.Host = hostURL
return &OAuth{
Config: c,
beginAuthHandler: echo.HandlerFunc(BeginAuthHandler),
completeAuthHandler: CompleteUserAuth,
}
} | go | func New(hostURL string, cfg *Config) *OAuth {
c := DefaultConfig().MergeSingle(cfg)
c.Host = hostURL
return &OAuth{
Config: c,
beginAuthHandler: echo.HandlerFunc(BeginAuthHandler),
completeAuthHandler: CompleteUserAuth,
}
} | [
"func",
"New",
"(",
"hostURL",
"string",
",",
"cfg",
"*",
"Config",
")",
"*",
"OAuth",
"{",
"c",
":=",
"DefaultConfig",
"(",
")",
".",
"MergeSingle",
"(",
"cfg",
")",
"\n",
"c",
".",
"Host",
"=",
"hostURL",
"\n",
"return",
"&",
"OAuth",
"{",
"Confi... | // New returns a new OAuth plugin
// receives one parameter of type 'Config' | [
"New",
"returns",
"a",
"new",
"OAuth",
"plugin",
"receives",
"one",
"parameter",
"of",
"type",
"Config"
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/handler/oauth2/auth2.go#L39-L47 |
151,049 | webx-top/echo | handler/oauth2/auth2.go | Wrapper | func (p *OAuth) Wrapper(e *echo.Echo, middlewares ...interface{}) {
p.Config.GenerateProviders()
g := e.Group(p.Config.Path, middlewares...)
// set the mux path to handle the registered providers
g.Get("/login/:provider", p.beginAuthHandler)
authMiddleware := func(h echo.Handler) echo.Handler {
return echo.HandlerFunc(func(ctx echo.Context) error {
user, err := p.completeAuthHandler(ctx)
if err != nil {
return echo.NewHTTPError(http.StatusUnauthorized, err.Error())
}
ctx.Set(p.Config.ContextKey, user)
return h.Handle(ctx)
})
}
p.successHandlers = append([]interface{}{authMiddleware}, p.successHandlers...)
lastIndex := len(p.successHandlers) - 1
if lastIndex == 0 {
g.Get("/callback/:provider", func(ctx echo.Context) error {
return ctx.String(`Success Handler is not set`)
}, p.successHandlers...)
} else {
g.Get("/callback/:provider", p.successHandlers[lastIndex], p.successHandlers[0:lastIndex]...)
}
// register the error handler
if p.failHandler != nil {
e.SetHTTPErrorHandler(p.failHandler)
}
} | go | func (p *OAuth) Wrapper(e *echo.Echo, middlewares ...interface{}) {
p.Config.GenerateProviders()
g := e.Group(p.Config.Path, middlewares...)
// set the mux path to handle the registered providers
g.Get("/login/:provider", p.beginAuthHandler)
authMiddleware := func(h echo.Handler) echo.Handler {
return echo.HandlerFunc(func(ctx echo.Context) error {
user, err := p.completeAuthHandler(ctx)
if err != nil {
return echo.NewHTTPError(http.StatusUnauthorized, err.Error())
}
ctx.Set(p.Config.ContextKey, user)
return h.Handle(ctx)
})
}
p.successHandlers = append([]interface{}{authMiddleware}, p.successHandlers...)
lastIndex := len(p.successHandlers) - 1
if lastIndex == 0 {
g.Get("/callback/:provider", func(ctx echo.Context) error {
return ctx.String(`Success Handler is not set`)
}, p.successHandlers...)
} else {
g.Get("/callback/:provider", p.successHandlers[lastIndex], p.successHandlers[0:lastIndex]...)
}
// register the error handler
if p.failHandler != nil {
e.SetHTTPErrorHandler(p.failHandler)
}
} | [
"func",
"(",
"p",
"*",
"OAuth",
")",
"Wrapper",
"(",
"e",
"*",
"echo",
".",
"Echo",
",",
"middlewares",
"...",
"interface",
"{",
"}",
")",
"{",
"p",
".",
"Config",
".",
"GenerateProviders",
"(",
")",
"\n\n",
"g",
":=",
"e",
".",
"Group",
"(",
"p"... | // Wrapper register the oauth route | [
"Wrapper",
"register",
"the",
"oauth",
"route"
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/handler/oauth2/auth2.go#L82-L114 |
151,050 | webx-top/echo | middleware/auth_basic.go | BasicAuth | func BasicAuth(fn BasicValidateFunc, skipper ...echo.Skipper) echo.MiddlewareFunc {
var isSkiped echo.Skipper
if len(skipper) > 0 {
isSkiped = skipper[0]
} else {
isSkiped = echo.DefaultSkipper
}
return func(h echo.Handler) echo.Handler {
return echo.HandlerFunc(func(c echo.Context) error {
if isSkiped(c) {
return h.Handle(c)
}
auth := c.Request().Header().Get(echo.HeaderAuthorization)
l := len(basic)
if len(auth) > l+1 && auth[:l] == basic {
b, err := base64.StdEncoding.DecodeString(auth[l+1:])
if err == nil {
cred := string(b)
for i := 0; i < len(cred); i++ {
if cred[i] == ':' {
// Verify credentials
if fn(cred[:i], cred[i+1:]) {
return h.Handle(c)
}
}
}
}
}
c.Response().Header().Set(echo.HeaderWWWAuthenticate, basic+" realm=Restricted")
return echo.NewHTTPError(http.StatusUnauthorized)
})
}
} | go | func BasicAuth(fn BasicValidateFunc, skipper ...echo.Skipper) echo.MiddlewareFunc {
var isSkiped echo.Skipper
if len(skipper) > 0 {
isSkiped = skipper[0]
} else {
isSkiped = echo.DefaultSkipper
}
return func(h echo.Handler) echo.Handler {
return echo.HandlerFunc(func(c echo.Context) error {
if isSkiped(c) {
return h.Handle(c)
}
auth := c.Request().Header().Get(echo.HeaderAuthorization)
l := len(basic)
if len(auth) > l+1 && auth[:l] == basic {
b, err := base64.StdEncoding.DecodeString(auth[l+1:])
if err == nil {
cred := string(b)
for i := 0; i < len(cred); i++ {
if cred[i] == ':' {
// Verify credentials
if fn(cred[:i], cred[i+1:]) {
return h.Handle(c)
}
}
}
}
}
c.Response().Header().Set(echo.HeaderWWWAuthenticate, basic+" realm=Restricted")
return echo.NewHTTPError(http.StatusUnauthorized)
})
}
} | [
"func",
"BasicAuth",
"(",
"fn",
"BasicValidateFunc",
",",
"skipper",
"...",
"echo",
".",
"Skipper",
")",
"echo",
".",
"MiddlewareFunc",
"{",
"var",
"isSkiped",
"echo",
".",
"Skipper",
"\n",
"if",
"len",
"(",
"skipper",
")",
">",
"0",
"{",
"isSkiped",
"="... | // BasicAuth returns an HTTP basic authentication middleware.
//
// For valid credentials it calls the next handler.
// For invalid credentials, it sends "401 - Unauthorized" response. | [
"BasicAuth",
"returns",
"an",
"HTTP",
"basic",
"authentication",
"middleware",
".",
"For",
"valid",
"credentials",
"it",
"calls",
"the",
"next",
"handler",
".",
"For",
"invalid",
"credentials",
"it",
"sends",
"401",
"-",
"Unauthorized",
"response",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/auth_basic.go#L22-L55 |
151,051 | webx-top/echo | echo.go | Use | func (e *Echo) Use(middleware ...interface{}) {
for _, m := range middleware {
e.ValidMiddleware(m)
e.middleware = append(e.middleware, m)
if e.MiddlewareDebug {
e.logger.Debugf(`Middleware[Use](%p): [] -> %s `, m, HandlerName(m))
}
}
} | go | func (e *Echo) Use(middleware ...interface{}) {
for _, m := range middleware {
e.ValidMiddleware(m)
e.middleware = append(e.middleware, m)
if e.MiddlewareDebug {
e.logger.Debugf(`Middleware[Use](%p): [] -> %s `, m, HandlerName(m))
}
}
} | [
"func",
"(",
"e",
"*",
"Echo",
")",
"Use",
"(",
"middleware",
"...",
"interface",
"{",
"}",
")",
"{",
"for",
"_",
",",
"m",
":=",
"range",
"middleware",
"{",
"e",
".",
"ValidMiddleware",
"(",
"m",
")",
"\n",
"e",
".",
"middleware",
"=",
"append",
... | // Use adds handler to the middleware chain. | [
"Use",
"adds",
"handler",
"to",
"the",
"middleware",
"chain",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/echo.go#L271-L279 |
151,052 | webx-top/echo | echo.go | PreUse | func (e *Echo) PreUse(middleware ...interface{}) {
var middlewares []interface{}
for _, m := range middleware {
e.ValidMiddleware(m)
middlewares = append(middlewares, m)
if e.MiddlewareDebug {
e.logger.Debugf(`Middleware[Pre](%p): [] -> %s`, m, HandlerName(m))
}
}
e.middleware = append(middlewares, e.middleware...)
} | go | func (e *Echo) PreUse(middleware ...interface{}) {
var middlewares []interface{}
for _, m := range middleware {
e.ValidMiddleware(m)
middlewares = append(middlewares, m)
if e.MiddlewareDebug {
e.logger.Debugf(`Middleware[Pre](%p): [] -> %s`, m, HandlerName(m))
}
}
e.middleware = append(middlewares, e.middleware...)
} | [
"func",
"(",
"e",
"*",
"Echo",
")",
"PreUse",
"(",
"middleware",
"...",
"interface",
"{",
"}",
")",
"{",
"var",
"middlewares",
"[",
"]",
"interface",
"{",
"}",
"\n",
"for",
"_",
",",
"m",
":=",
"range",
"middleware",
"{",
"e",
".",
"ValidMiddleware",... | // PreUse adds handler to the middleware chain. | [
"PreUse",
"adds",
"handler",
"to",
"the",
"middleware",
"chain",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/echo.go#L287-L297 |
151,053 | webx-top/echo | echo.go | File | func (e *Echo) File(path, file string) {
e.Get(path, func(c Context) error {
return c.File(file)
})
} | go | func (e *Echo) File(path, file string) {
e.Get(path, func(c Context) error {
return c.File(file)
})
} | [
"func",
"(",
"e",
"*",
"Echo",
")",
"File",
"(",
"path",
",",
"file",
"string",
")",
"{",
"e",
".",
"Get",
"(",
"path",
",",
"func",
"(",
"c",
"Context",
")",
"error",
"{",
"return",
"c",
".",
"File",
"(",
"file",
")",
"\n",
"}",
")",
"\n",
... | // File registers a new route with path to serve a static file. | [
"File",
"registers",
"a",
"new",
"route",
"with",
"path",
"to",
"serve",
"a",
"static",
"file",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/echo.go#L397-L401 |
151,054 | webx-top/echo | echo.go | RebuildRouter | func (e *Echo) RebuildRouter(args ...[]*Route) {
routes := e.router.routes
if len(args) > 0 {
routes = args[0]
}
e.router = NewRouter(e)
for i, r := range routes {
//e.logger.Debugf(`%p rebuild: %#v`, e, *r)
r.apply(e)
e.router.Add(r, i)
if _, ok := e.router.nroute[r.HandlerName]; !ok {
e.router.nroute[r.HandlerName] = []int{i}
} else {
e.router.nroute[r.HandlerName] = append(e.router.nroute[r.HandlerName], i)
}
}
e.router.routes = routes
e.head = nil
} | go | func (e *Echo) RebuildRouter(args ...[]*Route) {
routes := e.router.routes
if len(args) > 0 {
routes = args[0]
}
e.router = NewRouter(e)
for i, r := range routes {
//e.logger.Debugf(`%p rebuild: %#v`, e, *r)
r.apply(e)
e.router.Add(r, i)
if _, ok := e.router.nroute[r.HandlerName]; !ok {
e.router.nroute[r.HandlerName] = []int{i}
} else {
e.router.nroute[r.HandlerName] = append(e.router.nroute[r.HandlerName], i)
}
}
e.router.routes = routes
e.head = nil
} | [
"func",
"(",
"e",
"*",
"Echo",
")",
"RebuildRouter",
"(",
"args",
"...",
"[",
"]",
"*",
"Route",
")",
"{",
"routes",
":=",
"e",
".",
"router",
".",
"routes",
"\n",
"if",
"len",
"(",
"args",
")",
">",
"0",
"{",
"routes",
"=",
"args",
"[",
"0",
... | // RebuildRouter rebuild router | [
"RebuildRouter",
"rebuild",
"router"
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/echo.go#L471-L490 |
151,055 | webx-top/echo | context_x_request.go | P | func (c *xContext) P(i int, defaults ...string) (value string) {
l := len(c.pnames)
if i < l {
value = c.pvalues[i]
}
if len(value) == 0 && len(defaults) > 0 {
return defaults[0]
}
return
} | go | func (c *xContext) P(i int, defaults ...string) (value string) {
l := len(c.pnames)
if i < l {
value = c.pvalues[i]
}
if len(value) == 0 && len(defaults) > 0 {
return defaults[0]
}
return
} | [
"func",
"(",
"c",
"*",
"xContext",
")",
"P",
"(",
"i",
"int",
",",
"defaults",
"...",
"string",
")",
"(",
"value",
"string",
")",
"{",
"l",
":=",
"len",
"(",
"c",
".",
"pnames",
")",
"\n",
"if",
"i",
"<",
"l",
"{",
"value",
"=",
"c",
".",
"... | // P returns path parameter by index. | [
"P",
"returns",
"path",
"parameter",
"by",
"index",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/context_x_request.go#L26-L35 |
151,056 | webx-top/echo | middleware/ratelimit/middleware.go | New | func New(max int64, ttl time.Duration) *config.Limiter {
return config.NewLimiter(max, ttl)
} | go | func New(max int64, ttl time.Duration) *config.Limiter {
return config.NewLimiter(max, ttl)
} | [
"func",
"New",
"(",
"max",
"int64",
",",
"ttl",
"time",
".",
"Duration",
")",
"*",
"config",
".",
"Limiter",
"{",
"return",
"config",
".",
"NewLimiter",
"(",
"max",
",",
"ttl",
")",
"\n",
"}"
] | // New is a convenience function to config.NewLimiter. | [
"New",
"is",
"a",
"convenience",
"function",
"to",
"config",
".",
"NewLimiter",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/ratelimit/middleware.go#L65-L67 |
151,057 | webx-top/echo | middleware/ratelimit/middleware.go | LimitByKeysWithCustomTokenBucketTTL | func LimitByKeysWithCustomTokenBucketTTL(limiter *config.Limiter, keys []string, bucketExpireTTL time.Duration) *echo.HTTPError {
if limiter.LimitReachedWithCustomTokenBucketTTL(strings.Join(keys, "|"), bucketExpireTTL) {
return echo.NewHTTPError(limiter.StatusCode, limiter.Message)
}
return nil
} | go | func LimitByKeysWithCustomTokenBucketTTL(limiter *config.Limiter, keys []string, bucketExpireTTL time.Duration) *echo.HTTPError {
if limiter.LimitReachedWithCustomTokenBucketTTL(strings.Join(keys, "|"), bucketExpireTTL) {
return echo.NewHTTPError(limiter.StatusCode, limiter.Message)
}
return nil
} | [
"func",
"LimitByKeysWithCustomTokenBucketTTL",
"(",
"limiter",
"*",
"config",
".",
"Limiter",
",",
"keys",
"[",
"]",
"string",
",",
"bucketExpireTTL",
"time",
".",
"Duration",
")",
"*",
"echo",
".",
"HTTPError",
"{",
"if",
"limiter",
".",
"LimitReachedWithCustom... | // LimitByKeysWithCustomTokenBucketTTL keeps track number of request made by keys separated by pipe.
// It returns HTTPError when limit is exceeded.
// User can define a TTL for the key to expire | [
"LimitByKeysWithCustomTokenBucketTTL",
"keeps",
"track",
"number",
"of",
"request",
"made",
"by",
"keys",
"separated",
"by",
"pipe",
".",
"It",
"returns",
"HTTPError",
"when",
"limit",
"is",
"exceeded",
".",
"User",
"can",
"define",
"a",
"TTL",
"for",
"the",
"... | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/ratelimit/middleware.go#L91-L97 |
151,058 | webx-top/echo | middleware/ratelimit/middleware.go | SetResponseHeaders | func SetResponseHeaders(limiter *config.Limiter, w engine.Response) {
w.Header().Add("X-Rate-Limit-Limit", strconv.FormatInt(limiter.Max, 10))
w.Header().Add("X-Rate-Limit-Duration", limiter.TTL.String())
} | go | func SetResponseHeaders(limiter *config.Limiter, w engine.Response) {
w.Header().Add("X-Rate-Limit-Limit", strconv.FormatInt(limiter.Max, 10))
w.Header().Add("X-Rate-Limit-Duration", limiter.TTL.String())
} | [
"func",
"SetResponseHeaders",
"(",
"limiter",
"*",
"config",
".",
"Limiter",
",",
"w",
"engine",
".",
"Response",
")",
"{",
"w",
".",
"Header",
"(",
")",
".",
"Add",
"(",
"\"",
"\"",
",",
"strconv",
".",
"FormatInt",
"(",
"limiter",
".",
"Max",
",",
... | // SetResponseHeaders configures X-Rate-Limit-Limit and X-Rate-Limit-Duration | [
"SetResponseHeaders",
"configures",
"X",
"-",
"Rate",
"-",
"Limit",
"-",
"Limit",
"and",
"X",
"-",
"Rate",
"-",
"Limit",
"-",
"Duration"
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/ratelimit/middleware.go#L100-L103 |
151,059 | webx-top/echo | middleware/ratelimit/config/config.go | NewLimiter | func NewLimiter(max int64, ttl time.Duration) *Limiter {
limiter := &Limiter{Max: max, TTL: ttl}
limiter.Message = "You have reached maximum request limit."
limiter.StatusCode = 429
limiter.IPLookups = []string{"RemoteAddr", "X-Forwarded-For", "X-Real-IP"}
limiter.tokenBucketsNoTTL = make(map[string]*rate.Limiter)
return limiter
} | go | func NewLimiter(max int64, ttl time.Duration) *Limiter {
limiter := &Limiter{Max: max, TTL: ttl}
limiter.Message = "You have reached maximum request limit."
limiter.StatusCode = 429
limiter.IPLookups = []string{"RemoteAddr", "X-Forwarded-For", "X-Real-IP"}
limiter.tokenBucketsNoTTL = make(map[string]*rate.Limiter)
return limiter
} | [
"func",
"NewLimiter",
"(",
"max",
"int64",
",",
"ttl",
"time",
".",
"Duration",
")",
"*",
"Limiter",
"{",
"limiter",
":=",
"&",
"Limiter",
"{",
"Max",
":",
"max",
",",
"TTL",
":",
"ttl",
"}",
"\n",
"limiter",
".",
"Message",
"=",
"\"",
"\"",
"\n",
... | // NewLimiter is a constructor for Limiter. | [
"NewLimiter",
"is",
"a",
"constructor",
"for",
"Limiter",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/ratelimit/config/config.go#L13-L22 |
151,060 | webx-top/echo | middleware/ratelimit/config/config.go | NewLimiterExpiringBuckets | func NewLimiterExpiringBuckets(max int64, ttl, bucketDefaultExpirationTTL, bucketExpireJobInterval time.Duration) *Limiter {
limiter := NewLimiter(max, ttl).SetExpiring(bucketDefaultExpirationTTL, bucketExpireJobInterval)
return limiter
} | go | func NewLimiterExpiringBuckets(max int64, ttl, bucketDefaultExpirationTTL, bucketExpireJobInterval time.Duration) *Limiter {
limiter := NewLimiter(max, ttl).SetExpiring(bucketDefaultExpirationTTL, bucketExpireJobInterval)
return limiter
} | [
"func",
"NewLimiterExpiringBuckets",
"(",
"max",
"int64",
",",
"ttl",
",",
"bucketDefaultExpirationTTL",
",",
"bucketExpireJobInterval",
"time",
".",
"Duration",
")",
"*",
"Limiter",
"{",
"limiter",
":=",
"NewLimiter",
"(",
"max",
",",
"ttl",
")",
".",
"SetExpir... | // NewLimiterExpiringBuckets constructs Limiter with expirable TokenBuckets. | [
"NewLimiterExpiringBuckets",
"constructs",
"Limiter",
"with",
"expirable",
"TokenBuckets",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/ratelimit/config/config.go#L25-L28 |
151,061 | webx-top/echo | middleware/ratelimit/config/config.go | LimitReachedWithCustomTokenBucketTTL | func (l *Limiter) LimitReachedWithCustomTokenBucketTTL(key string, tokenBucketTTL time.Duration) bool {
if l.isUsingTokenBucketsWithTTL() {
return l.limitReachedWithCustomTokenBucketTTL(key, tokenBucketTTL)
}
return l.limitReachedNoTokenBucketTTL(key)
} | go | func (l *Limiter) LimitReachedWithCustomTokenBucketTTL(key string, tokenBucketTTL time.Duration) bool {
if l.isUsingTokenBucketsWithTTL() {
return l.limitReachedWithCustomTokenBucketTTL(key, tokenBucketTTL)
}
return l.limitReachedNoTokenBucketTTL(key)
} | [
"func",
"(",
"l",
"*",
"Limiter",
")",
"LimitReachedWithCustomTokenBucketTTL",
"(",
"key",
"string",
",",
"tokenBucketTTL",
"time",
".",
"Duration",
")",
"bool",
"{",
"if",
"l",
".",
"isUsingTokenBucketsWithTTL",
"(",
")",
"{",
"return",
"l",
".",
"limitReache... | // LimitReachedWithCustomTokenBucketTTL returns a bool indicating if the Bucket identified by key ran out of tokens.
// This public API allows user to define custom expiration TTL on the key. | [
"LimitReachedWithCustomTokenBucketTTL",
"returns",
"a",
"bool",
"indicating",
"if",
"the",
"Bucket",
"identified",
"by",
"key",
"ran",
"out",
"of",
"tokens",
".",
"This",
"public",
"API",
"allows",
"user",
"to",
"define",
"custom",
"expiration",
"TTL",
"on",
"th... | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/ratelimit/config/config.go#L151-L156 |
151,062 | webx-top/echo | defaults/defaults.go | Match | func Match(methods []string, path string, h interface{}, m ...interface{}) {
Default.Match(methods, path, h, m...)
} | go | func Match(methods []string, path string, h interface{}, m ...interface{}) {
Default.Match(methods, path, h, m...)
} | [
"func",
"Match",
"(",
"methods",
"[",
"]",
"string",
",",
"path",
"string",
",",
"h",
"interface",
"{",
"}",
",",
"m",
"...",
"interface",
"{",
"}",
")",
"{",
"Default",
".",
"Match",
"(",
"methods",
",",
"path",
",",
"h",
",",
"m",
"...",
")",
... | // Match adds a route > handler to the router for multiple HTTP methods provided. | [
"Match",
"adds",
"a",
"route",
">",
"handler",
"to",
"the",
"router",
"for",
"multiple",
"HTTP",
"methods",
"provided",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/defaults/defaults.go#L170-L172 |
151,063 | webx-top/echo | handler/mvc/application.go | Tree | func (s *Application) Tree(args ...*echo.Echo) (r map[string]map[string]map[string]map[string]string) {
core := s.Core
if len(args) > 0 {
core = args[0]
}
nrs := core.NamedRoutes()
rs := core.Routes()
r = map[string]map[string]map[string]map[string]string{}
for name, indexes := range nrs {
p := strings.LastIndex(name, `/`)
s := strings.Split(name[p+1:], `.`)
var appName, ctlName, actName string
switch len(s) {
case 3:
if !strings.HasSuffix(s[2], `-fm`) {
continue
}
actName = strings.TrimSuffix(s[2], `-fm`)
ctlName = strings.TrimPrefix(s[1], `(`)
ctlName = strings.TrimPrefix(ctlName, `*`)
ctlName = strings.TrimSuffix(ctlName, `)`)
p2 := strings.LastIndex(name[0:p], `/`)
appName = name[p2+1 : p]
default:
continue
}
if _, ok := r[appName]; !ok {
r[appName] = map[string]map[string]map[string]string{}
}
if _, ok := r[appName][ctlName]; !ok {
r[appName][ctlName] = map[string]map[string]string{}
}
if _, ok := r[appName][ctlName][actName]; !ok {
r[appName][ctlName][actName] = map[string]string{}
for _, index := range indexes {
route := rs[index]
if _, ok := r[appName][ctlName][actName][route.Method]; !ok {
r[appName][ctlName][actName][route.Method] = route.Method
}
}
}
}
return
} | go | func (s *Application) Tree(args ...*echo.Echo) (r map[string]map[string]map[string]map[string]string) {
core := s.Core
if len(args) > 0 {
core = args[0]
}
nrs := core.NamedRoutes()
rs := core.Routes()
r = map[string]map[string]map[string]map[string]string{}
for name, indexes := range nrs {
p := strings.LastIndex(name, `/`)
s := strings.Split(name[p+1:], `.`)
var appName, ctlName, actName string
switch len(s) {
case 3:
if !strings.HasSuffix(s[2], `-fm`) {
continue
}
actName = strings.TrimSuffix(s[2], `-fm`)
ctlName = strings.TrimPrefix(s[1], `(`)
ctlName = strings.TrimPrefix(ctlName, `*`)
ctlName = strings.TrimSuffix(ctlName, `)`)
p2 := strings.LastIndex(name[0:p], `/`)
appName = name[p2+1 : p]
default:
continue
}
if _, ok := r[appName]; !ok {
r[appName] = map[string]map[string]map[string]string{}
}
if _, ok := r[appName][ctlName]; !ok {
r[appName][ctlName] = map[string]map[string]string{}
}
if _, ok := r[appName][ctlName][actName]; !ok {
r[appName][ctlName][actName] = map[string]string{}
for _, index := range indexes {
route := rs[index]
if _, ok := r[appName][ctlName][actName][route.Method]; !ok {
r[appName][ctlName][actName][route.Method] = route.Method
}
}
}
}
return
} | [
"func",
"(",
"s",
"*",
"Application",
")",
"Tree",
"(",
"args",
"...",
"*",
"echo",
".",
"Echo",
")",
"(",
"r",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"cor... | // Tree module -> controller -> action -> HTTP-METHODS | [
"Tree",
"module",
"-",
">",
"controller",
"-",
">",
"action",
"-",
">",
"HTTP",
"-",
"METHODS"
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/handler/mvc/application.go#L654-L697 |
151,064 | webx-top/echo | middleware/render/middleware.go | Middleware | func Middleware(d echo.Renderer) echo.MiddlewareFunc {
return func(h echo.Handler) echo.Handler {
return echo.HandlerFunc(func(c echo.Context) error {
c.SetRenderer(d)
return h.Handle(c)
})
}
} | go | func Middleware(d echo.Renderer) echo.MiddlewareFunc {
return func(h echo.Handler) echo.Handler {
return echo.HandlerFunc(func(c echo.Context) error {
c.SetRenderer(d)
return h.Handle(c)
})
}
} | [
"func",
"Middleware",
"(",
"d",
"echo",
".",
"Renderer",
")",
"echo",
".",
"MiddlewareFunc",
"{",
"return",
"func",
"(",
"h",
"echo",
".",
"Handler",
")",
"echo",
".",
"Handler",
"{",
"return",
"echo",
".",
"HandlerFunc",
"(",
"func",
"(",
"c",
"echo",... | // Middleware set renderer | [
"Middleware",
"set",
"renderer"
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/render/middleware.go#L67-L74 |
151,065 | webx-top/echo | middleware/bytes/bytes.go | Format | func (*Bytes) Format(b int64) string {
multiple := ""
value := float64(b)
switch {
case b < KB:
return strconv.FormatInt(b, 10) + "B"
case b < MB:
value /= KB
multiple = "KB"
case b < MB:
value /= KB
multiple = "KB"
case b < GB:
value /= MB
multiple = "MB"
case b < TB:
value /= GB
multiple = "GB"
case b < PB:
value /= TB
multiple = "TB"
case b < EB:
value /= PB
multiple = "PB"
}
return fmt.Sprintf("%.02f%s", value, multiple)
} | go | func (*Bytes) Format(b int64) string {
multiple := ""
value := float64(b)
switch {
case b < KB:
return strconv.FormatInt(b, 10) + "B"
case b < MB:
value /= KB
multiple = "KB"
case b < MB:
value /= KB
multiple = "KB"
case b < GB:
value /= MB
multiple = "MB"
case b < TB:
value /= GB
multiple = "GB"
case b < PB:
value /= TB
multiple = "TB"
case b < EB:
value /= PB
multiple = "PB"
}
return fmt.Sprintf("%.02f%s", value, multiple)
} | [
"func",
"(",
"*",
"Bytes",
")",
"Format",
"(",
"b",
"int64",
")",
"string",
"{",
"multiple",
":=",
"\"",
"\"",
"\n",
"value",
":=",
"float64",
"(",
"b",
")",
"\n\n",
"switch",
"{",
"case",
"b",
"<",
"KB",
":",
"return",
"strconv",
".",
"FormatInt",... | // Format formats bytes integer to human readable string.
// For example, 31323 bytes will return 30.59KB. | [
"Format",
"formats",
"bytes",
"integer",
"to",
"human",
"readable",
"string",
".",
"For",
"example",
"31323",
"bytes",
"will",
"return",
"30",
".",
"59KB",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/bytes/bytes.go#L36-L64 |
151,066 | webx-top/echo | engine/fasthttp/request.go | BasicAuth | func (r *Request) BasicAuth() (username, password string, ok bool) {
auth := r.Header().Get(echo.HeaderAuthorization)
if auth == "" {
return
}
return parseBasicAuth(auth)
} | go | func (r *Request) BasicAuth() (username, password string, ok bool) {
auth := r.Header().Get(echo.HeaderAuthorization)
if auth == "" {
return
}
return parseBasicAuth(auth)
} | [
"func",
"(",
"r",
"*",
"Request",
")",
"BasicAuth",
"(",
")",
"(",
"username",
",",
"password",
"string",
",",
"ok",
"bool",
")",
"{",
"auth",
":=",
"r",
".",
"Header",
"(",
")",
".",
"Get",
"(",
"echo",
".",
"HeaderAuthorization",
")",
"\n",
"if",... | // BasicAuth returns the username and password provided in the request's
// Authorization header, if the request uses HTTP Basic Authentication.
// See RFC 2617, Section 2. | [
"BasicAuth",
"returns",
"the",
"username",
"and",
"password",
"provided",
"in",
"the",
"request",
"s",
"Authorization",
"header",
"if",
"the",
"request",
"uses",
"HTTP",
"Basic",
"Authentication",
".",
"See",
"RFC",
"2617",
"Section",
"2",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/engine/fasthttp/request.go#L181-L187 |
151,067 | webx-top/echo | handler/mvc/static/minify/jsmin.go | MinifyJS | func MinifyJS(script []byte) (minified []byte, err error) {
var buf bytes.Buffer
w := bufio.NewWriter(&buf)
r := bufio.NewReader(bytes.NewReader(script))
m := new(minifier)
m.init(r, w)
m.run()
if m.err != nil {
return nil, err
}
w.Flush()
minified = buf.Bytes()
if len(minified) > 0 && minified[0] == '\n' {
minified = minified[1:]
}
return minified, nil
} | go | func MinifyJS(script []byte) (minified []byte, err error) {
var buf bytes.Buffer
w := bufio.NewWriter(&buf)
r := bufio.NewReader(bytes.NewReader(script))
m := new(minifier)
m.init(r, w)
m.run()
if m.err != nil {
return nil, err
}
w.Flush()
minified = buf.Bytes()
if len(minified) > 0 && minified[0] == '\n' {
minified = minified[1:]
}
return minified, nil
} | [
"func",
"MinifyJS",
"(",
"script",
"[",
"]",
"byte",
")",
"(",
"minified",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"w",
":=",
"bufio",
".",
"NewWriter",
"(",
"&",
"buf",
")",
"\n",
"r",
":=",
... | // Minify returns a minified script or an error. | [
"Minify",
"returns",
"a",
"minified",
"script",
"or",
"an",
"error",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/handler/mvc/static/minify/jsmin.go#L329-L347 |
151,068 | webx-top/echo | middleware/csrf.go | csrfTokenFromHeader | func csrfTokenFromHeader(header string) csrfTokenExtractor {
return func(c echo.Context) (string, error) {
return c.Request().Header().Get(header), nil
}
} | go | func csrfTokenFromHeader(header string) csrfTokenExtractor {
return func(c echo.Context) (string, error) {
return c.Request().Header().Get(header), nil
}
} | [
"func",
"csrfTokenFromHeader",
"(",
"header",
"string",
")",
"csrfTokenExtractor",
"{",
"return",
"func",
"(",
"c",
"echo",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"c",
".",
"Request",
"(",
")",
".",
"Header",
"(",
")",
".... | // csrfTokenFromForm returns a `csrfTokenExtractor` that extracts token from the
// provided request header. | [
"csrfTokenFromForm",
"returns",
"a",
"csrfTokenExtractor",
"that",
"extracts",
"token",
"from",
"the",
"provided",
"request",
"header",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/csrf.go#L169-L173 |
151,069 | webx-top/echo | middleware/csrf.go | csrfTokenFromForm | func csrfTokenFromForm(param string) csrfTokenExtractor {
return func(c echo.Context) (string, error) {
token := c.Form(param)
if token == "" {
return "", errors.New("empty csrf token in form param")
}
return token, nil
}
} | go | func csrfTokenFromForm(param string) csrfTokenExtractor {
return func(c echo.Context) (string, error) {
token := c.Form(param)
if token == "" {
return "", errors.New("empty csrf token in form param")
}
return token, nil
}
} | [
"func",
"csrfTokenFromForm",
"(",
"param",
"string",
")",
"csrfTokenExtractor",
"{",
"return",
"func",
"(",
"c",
"echo",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"token",
":=",
"c",
".",
"Form",
"(",
"param",
")",
"\n",
"if",
"token"... | // csrfTokenFromForm returns a `csrfTokenExtractor` that extracts token from the
// provided form parameter. | [
"csrfTokenFromForm",
"returns",
"a",
"csrfTokenExtractor",
"that",
"extracts",
"token",
"from",
"the",
"provided",
"form",
"parameter",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/csrf.go#L177-L185 |
151,070 | webx-top/echo | middleware/csrf.go | csrfTokenFromQuery | func csrfTokenFromQuery(param string) csrfTokenExtractor {
return func(c echo.Context) (string, error) {
token := c.Query(param)
if token == "" {
return "", errors.New("empty csrf token in query param")
}
return token, nil
}
} | go | func csrfTokenFromQuery(param string) csrfTokenExtractor {
return func(c echo.Context) (string, error) {
token := c.Query(param)
if token == "" {
return "", errors.New("empty csrf token in query param")
}
return token, nil
}
} | [
"func",
"csrfTokenFromQuery",
"(",
"param",
"string",
")",
"csrfTokenExtractor",
"{",
"return",
"func",
"(",
"c",
"echo",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"token",
":=",
"c",
".",
"Query",
"(",
"param",
")",
"\n",
"if",
"toke... | // csrfTokenFromQuery returns a `csrfTokenExtractor` that extracts token from the
// provided query parameter. | [
"csrfTokenFromQuery",
"returns",
"a",
"csrfTokenExtractor",
"that",
"extracts",
"token",
"from",
"the",
"provided",
"query",
"parameter",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/csrf.go#L189-L197 |
151,071 | webx-top/echo | middleware/jwt/jwt.go | jwtFromHeader | func jwtFromHeader(header string) jwtExtractor {
return func(c echo.Context) (string, error) {
auth := c.Request().Header().Get(header)
l := len(bearer)
if len(auth) > l+1 && auth[:l] == bearer {
return auth[l+1:], nil
}
return "", errors.New("empty or invalid jwt in request header")
}
} | go | func jwtFromHeader(header string) jwtExtractor {
return func(c echo.Context) (string, error) {
auth := c.Request().Header().Get(header)
l := len(bearer)
if len(auth) > l+1 && auth[:l] == bearer {
return auth[l+1:], nil
}
return "", errors.New("empty or invalid jwt in request header")
}
} | [
"func",
"jwtFromHeader",
"(",
"header",
"string",
")",
"jwtExtractor",
"{",
"return",
"func",
"(",
"c",
"echo",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"auth",
":=",
"c",
".",
"Request",
"(",
")",
".",
"Header",
"(",
")",
".",
"... | // jwtFromHeader returns a `jwtExtractor` that extracts token from request header. | [
"jwtFromHeader",
"returns",
"a",
"jwtExtractor",
"that",
"extracts",
"token",
"from",
"request",
"header",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/jwt/jwt.go#L171-L180 |
151,072 | webx-top/echo | middleware/jwt/jwt.go | jwtFromQuery | func jwtFromQuery(param string) jwtExtractor {
return func(c echo.Context) (string, error) {
token := c.Query(param)
var err error
if len(token) == 0 {
return "", errors.New("empty jwt in query string")
}
return token, err
}
} | go | func jwtFromQuery(param string) jwtExtractor {
return func(c echo.Context) (string, error) {
token := c.Query(param)
var err error
if len(token) == 0 {
return "", errors.New("empty jwt in query string")
}
return token, err
}
} | [
"func",
"jwtFromQuery",
"(",
"param",
"string",
")",
"jwtExtractor",
"{",
"return",
"func",
"(",
"c",
"echo",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"token",
":=",
"c",
".",
"Query",
"(",
"param",
")",
"\n",
"var",
"err",
"error"... | // jwtFromQuery returns a `jwtExtractor` that extracts token from query string. | [
"jwtFromQuery",
"returns",
"a",
"jwtExtractor",
"that",
"extracts",
"token",
"from",
"query",
"string",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/jwt/jwt.go#L183-L192 |
151,073 | webx-top/echo | middleware/jwt/jwt.go | jwtFromCookie | func jwtFromCookie(name string) jwtExtractor {
return func(c echo.Context) (string, error) {
token := c.GetCookie(name)
if len(token) == 0 {
return "", errors.New("empty jwt in cookie")
}
return token, nil
}
} | go | func jwtFromCookie(name string) jwtExtractor {
return func(c echo.Context) (string, error) {
token := c.GetCookie(name)
if len(token) == 0 {
return "", errors.New("empty jwt in cookie")
}
return token, nil
}
} | [
"func",
"jwtFromCookie",
"(",
"name",
"string",
")",
"jwtExtractor",
"{",
"return",
"func",
"(",
"c",
"echo",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"token",
":=",
"c",
".",
"GetCookie",
"(",
"name",
")",
"\n",
"if",
"len",
"(",
... | // jwtFromCookie returns a `jwtExtractor` that extracts token from named cookie. | [
"jwtFromCookie",
"returns",
"a",
"jwtExtractor",
"that",
"extracts",
"token",
"from",
"named",
"cookie",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/jwt/jwt.go#L195-L203 |
151,074 | webx-top/echo | middleware/ipfilter/ipfilter.go | IPFilter | func IPFilter(config Config) echo.MiddlewareFuncd {
// Defaults
if config.Skipper == nil {
config.Skipper = DefaultConfig.Skipper
}
config.Init()
return func(next echo.Handler) echo.HandlerFunc {
return func(c echo.Context) error {
if config.Skipper(c) {
return next.Handle(c)
}
ip, _, _ := net.SplitHostPort(c.RealIP())
//show simple forbidden text
if !config.Filter().Allowed(ip) {
return echo.ErrForbidden
}
return next.Handle(c)
}
}
} | go | func IPFilter(config Config) echo.MiddlewareFuncd {
// Defaults
if config.Skipper == nil {
config.Skipper = DefaultConfig.Skipper
}
config.Init()
return func(next echo.Handler) echo.HandlerFunc {
return func(c echo.Context) error {
if config.Skipper(c) {
return next.Handle(c)
}
ip, _, _ := net.SplitHostPort(c.RealIP())
//show simple forbidden text
if !config.Filter().Allowed(ip) {
return echo.ErrForbidden
}
return next.Handle(c)
}
}
} | [
"func",
"IPFilter",
"(",
"config",
"Config",
")",
"echo",
".",
"MiddlewareFuncd",
"{",
"// Defaults",
"if",
"config",
".",
"Skipper",
"==",
"nil",
"{",
"config",
".",
"Skipper",
"=",
"DefaultConfig",
".",
"Skipper",
"\n",
"}",
"\n",
"config",
".",
"Init",
... | // IPFilter returns a IPFilter middleware with config. | [
"IPFilter",
"returns",
"a",
"IPFilter",
"middleware",
"with",
"config",
"."
] | e5bb0278c4184f8d0cf242950195de00085f1f4c | https://github.com/webx-top/echo/blob/e5bb0278c4184f8d0cf242950195de00085f1f4c/middleware/ipfilter/ipfilter.go#L55-L74 |
151,075 | tebeka/atexit | atexit.go | Register | func Register(handler func()) {
handlersLock.Lock()
defer handlersLock.Unlock()
handlers = append(handlers, handler)
} | go | func Register(handler func()) {
handlersLock.Lock()
defer handlersLock.Unlock()
handlers = append(handlers, handler)
} | [
"func",
"Register",
"(",
"handler",
"func",
"(",
")",
")",
"{",
"handlersLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"handlersLock",
".",
"Unlock",
"(",
")",
"\n",
"handlers",
"=",
"append",
"(",
"handlers",
",",
"handler",
")",
"\n",
"}"
] | // Register adds a handler, call atexit.Exit to invoke all handlers. | [
"Register",
"adds",
"a",
"handler",
"call",
"atexit",
".",
"Exit",
"to",
"invoke",
"all",
"handlers",
"."
] | 2896622543089a3b3fc51659ee2e4f3410f3e162 | https://github.com/tebeka/atexit/blob/2896622543089a3b3fc51659ee2e4f3410f3e162/atexit.go#L96-L100 |
151,076 | go-macaron/auth | basic.go | Basic | func Basic(username string, password string) macaron.Handler {
var siteAuth = base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
return func(res http.ResponseWriter, req *http.Request, c *macaron.Context) {
auth := req.Header.Get("Authorization")
if !SecureCompare(auth, basicPrefix+siteAuth) {
basicUnauthorized(res)
return
}
c.Map(User(username))
}
} | go | func Basic(username string, password string) macaron.Handler {
var siteAuth = base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
return func(res http.ResponseWriter, req *http.Request, c *macaron.Context) {
auth := req.Header.Get("Authorization")
if !SecureCompare(auth, basicPrefix+siteAuth) {
basicUnauthorized(res)
return
}
c.Map(User(username))
}
} | [
"func",
"Basic",
"(",
"username",
"string",
",",
"password",
"string",
")",
"macaron",
".",
"Handler",
"{",
"var",
"siteAuth",
"=",
"base64",
".",
"StdEncoding",
".",
"EncodeToString",
"(",
"[",
"]",
"byte",
"(",
"username",
"+",
"\"",
"\"",
"+",
"passwo... | // Basic returns a Handler that authenticates via Basic Auth. Writes a http.StatusUnauthorized
// if authentication fails. | [
"Basic",
"returns",
"a",
"Handler",
"that",
"authenticates",
"via",
"Basic",
"Auth",
".",
"Writes",
"a",
"http",
".",
"StatusUnauthorized",
"if",
"authentication",
"fails",
"."
] | 884c0e6c9b92ceebf12101d6cf1417fe0f61bcac | https://github.com/go-macaron/auth/blob/884c0e6c9b92ceebf12101d6cf1417fe0f61bcac/basic.go#L20-L30 |
151,077 | go-macaron/auth | bearer.go | Bearer | func Bearer(token string) macaron.Handler {
return func(res http.ResponseWriter, req *http.Request, c *macaron.Context) {
auth := req.Header.Get("Authorization")
if !SecureCompare(auth, bearerPrefix+token) {
bearerUnauthorized(res)
return
}
c.Map(User(""))
}
} | go | func Bearer(token string) macaron.Handler {
return func(res http.ResponseWriter, req *http.Request, c *macaron.Context) {
auth := req.Header.Get("Authorization")
if !SecureCompare(auth, bearerPrefix+token) {
bearerUnauthorized(res)
return
}
c.Map(User(""))
}
} | [
"func",
"Bearer",
"(",
"token",
"string",
")",
"macaron",
".",
"Handler",
"{",
"return",
"func",
"(",
"res",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
",",
"c",
"*",
"macaron",
".",
"Context",
")",
"{",
"auth",
":=",
"re... | // Bearer returns a Handler that authenticates via Bearer Auth. Writes a http.StatusUnauthorized
// if authentication fails. | [
"Bearer",
"returns",
"a",
"Handler",
"that",
"authenticates",
"via",
"Bearer",
"Auth",
".",
"Writes",
"a",
"http",
".",
"StatusUnauthorized",
"if",
"authentication",
"fails",
"."
] | 884c0e6c9b92ceebf12101d6cf1417fe0f61bcac | https://github.com/go-macaron/auth/blob/884c0e6c9b92ceebf12101d6cf1417fe0f61bcac/bearer.go#L13-L22 |
151,078 | go-macaron/auth | bearer.go | BearerFunc | func BearerFunc(authfn func(string) bool) macaron.Handler {
return func(res http.ResponseWriter, req *http.Request, c *macaron.Context) {
auth := req.Header.Get("Authorization")
n := len(bearerPrefix)
if len(auth) < n || auth[:n] != bearerPrefix {
bearerUnauthorized(res)
return
}
if !authfn(auth[n:]) {
bearerUnauthorized(res)
return
}
c.Map(User(""))
}
} | go | func BearerFunc(authfn func(string) bool) macaron.Handler {
return func(res http.ResponseWriter, req *http.Request, c *macaron.Context) {
auth := req.Header.Get("Authorization")
n := len(bearerPrefix)
if len(auth) < n || auth[:n] != bearerPrefix {
bearerUnauthorized(res)
return
}
if !authfn(auth[n:]) {
bearerUnauthorized(res)
return
}
c.Map(User(""))
}
} | [
"func",
"BearerFunc",
"(",
"authfn",
"func",
"(",
"string",
")",
"bool",
")",
"macaron",
".",
"Handler",
"{",
"return",
"func",
"(",
"res",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
",",
"c",
"*",
"macaron",
".",
"Context"... | // BearerFunc returns a Handler that authenticates via Bearer Auth using the provided function.
// The function should return true for a valid bearer token. | [
"BearerFunc",
"returns",
"a",
"Handler",
"that",
"authenticates",
"via",
"Bearer",
"Auth",
"using",
"the",
"provided",
"function",
".",
"The",
"function",
"should",
"return",
"true",
"for",
"a",
"valid",
"bearer",
"token",
"."
] | 884c0e6c9b92ceebf12101d6cf1417fe0f61bcac | https://github.com/go-macaron/auth/blob/884c0e6c9b92ceebf12101d6cf1417fe0f61bcac/bearer.go#L26-L40 |
151,079 | jlhawn/dockramp | build/builder.go | NewBuilder | func NewBuilder(daemonURL string, tlsConfig *tls.Config, contextDirectory, dockerfilePath, repoTag string) (*Builder, error) {
// Validate that the context directory exists.
stat, err := os.Stat(contextDirectory)
if err != nil {
return nil, fmt.Errorf("unable to access build context directory: %s", err)
}
if !stat.IsDir() {
return nil, fmt.Errorf("context must be a directory")
}
if dockerfilePath == "" {
// Use Default path.
dockerfilePath = filepath.Join(contextDirectory, "Dockerfile")
}
if _, err := os.Stat(dockerfilePath); err != nil {
return nil, fmt.Errorf("unable to access build file: %s", err)
}
ref, err := reference.Parse(repoTag)
if err != nil {
if err != reference.ErrNameEmpty {
return nil, fmt.Errorf("invalid tag: %s", err)
}
}
client, err := dockerclient.NewDockerClient(daemonURL, tlsConfig)
if err != nil {
return nil, fmt.Errorf("unable to initialize client: %s", err)
}
b := &Builder{
daemonURL: daemonURL,
tlsConfig: tlsConfig,
client: client,
contextDirectory: contextDirectory,
dockerfilePath: dockerfilePath,
ref: ref,
out: os.Stdout,
config: &config{
Labels: map[string]string{},
ExposedPorts: map[string]struct{}{},
Volumes: map[string]struct{}{},
},
}
// Register Dockerfile Directive Handlers
b.handlers = map[string]handlerFunc{
commands.Cmd: b.handleCmd,
commands.Copy: b.handleCopy,
commands.Entrypoint: b.handleEntrypoint,
commands.Env: b.handleEnv,
commands.Expose: b.handleExpose,
commands.Extract: b.handleExtract,
commands.From: b.handleFrom,
commands.Label: b.handleLabel,
commands.Maintainer: b.handleMaintainer,
commands.Run: b.handleRun,
commands.User: b.handleUser,
commands.Volume: b.handleVolume,
commands.Workdir: b.handleWorkdir,
// Not implemented for now:
commands.Add: b.handleAdd,
commands.Onbuild: b.handleOnbuild,
}
if err := b.loadCache(); err != nil {
return nil, fmt.Errorf("unable to load build cache: %s", err)
}
return b, nil
} | go | func NewBuilder(daemonURL string, tlsConfig *tls.Config, contextDirectory, dockerfilePath, repoTag string) (*Builder, error) {
// Validate that the context directory exists.
stat, err := os.Stat(contextDirectory)
if err != nil {
return nil, fmt.Errorf("unable to access build context directory: %s", err)
}
if !stat.IsDir() {
return nil, fmt.Errorf("context must be a directory")
}
if dockerfilePath == "" {
// Use Default path.
dockerfilePath = filepath.Join(contextDirectory, "Dockerfile")
}
if _, err := os.Stat(dockerfilePath); err != nil {
return nil, fmt.Errorf("unable to access build file: %s", err)
}
ref, err := reference.Parse(repoTag)
if err != nil {
if err != reference.ErrNameEmpty {
return nil, fmt.Errorf("invalid tag: %s", err)
}
}
client, err := dockerclient.NewDockerClient(daemonURL, tlsConfig)
if err != nil {
return nil, fmt.Errorf("unable to initialize client: %s", err)
}
b := &Builder{
daemonURL: daemonURL,
tlsConfig: tlsConfig,
client: client,
contextDirectory: contextDirectory,
dockerfilePath: dockerfilePath,
ref: ref,
out: os.Stdout,
config: &config{
Labels: map[string]string{},
ExposedPorts: map[string]struct{}{},
Volumes: map[string]struct{}{},
},
}
// Register Dockerfile Directive Handlers
b.handlers = map[string]handlerFunc{
commands.Cmd: b.handleCmd,
commands.Copy: b.handleCopy,
commands.Entrypoint: b.handleEntrypoint,
commands.Env: b.handleEnv,
commands.Expose: b.handleExpose,
commands.Extract: b.handleExtract,
commands.From: b.handleFrom,
commands.Label: b.handleLabel,
commands.Maintainer: b.handleMaintainer,
commands.Run: b.handleRun,
commands.User: b.handleUser,
commands.Volume: b.handleVolume,
commands.Workdir: b.handleWorkdir,
// Not implemented for now:
commands.Add: b.handleAdd,
commands.Onbuild: b.handleOnbuild,
}
if err := b.loadCache(); err != nil {
return nil, fmt.Errorf("unable to load build cache: %s", err)
}
return b, nil
} | [
"func",
"NewBuilder",
"(",
"daemonURL",
"string",
",",
"tlsConfig",
"*",
"tls",
".",
"Config",
",",
"contextDirectory",
",",
"dockerfilePath",
",",
"repoTag",
"string",
")",
"(",
"*",
"Builder",
",",
"error",
")",
"{",
"// Validate that the context directory exist... | // NewBuilder creates a new builder. | [
"NewBuilder",
"creates",
"a",
"new",
"builder",
"."
] | fa026f9d0ef7a388cc8487e601adc3ab8d508551 | https://github.com/jlhawn/dockramp/blob/fa026f9d0ef7a388cc8487e601adc3ab8d508551/build/builder.go#L69-L141 |
151,080 | jlhawn/dockramp | build/builder.go | Run | func (b *Builder) Run() error {
// Parse the Dockerfile.
dockerfile, err := os.Open(b.dockerfilePath)
if err != nil {
return fmt.Errorf("unable to open Dockerfile: %s", err)
}
defer dockerfile.Close()
commands, err := parser.Parse(dockerfile)
if err != nil {
return fmt.Errorf("unable to parse Dockerfile: %s", err)
}
if len(commands) == 0 {
return fmt.Errorf("no commands found in Dockerfile")
}
for i, command := range commands {
if err := b.dispatch(i, command); err != nil {
return err
}
}
// create container and commit if we need to (because of trailing
// metadata directives).
if b.uncommitted && !b.probeCache() {
b.containerID, err = b.createContainer([]string{"/bin/sh", "-c"}, []string{"#(nop)"}, false)
if err != nil {
return fmt.Errorf("unable to create container: %s", err)
}
if err := b.commit(); err != nil {
return fmt.Errorf("unable to commit container image: %s", err)
}
}
imageName := b.imageID
if named, hasName := b.ref.(reference.Named); hasName {
imageName = b.ref.String()
var tag string
if tagged, isTagged := named.(reference.Tagged); isTagged {
tag = tagged.Tag()
}
if err := b.setTag(b.imageID, named.Name(), tag); err != nil {
return fmt.Errorf("unable to tag built image: %s", err)
}
}
fmt.Fprintf(b.out, "Successfully built %s\n", imageName)
return nil
} | go | func (b *Builder) Run() error {
// Parse the Dockerfile.
dockerfile, err := os.Open(b.dockerfilePath)
if err != nil {
return fmt.Errorf("unable to open Dockerfile: %s", err)
}
defer dockerfile.Close()
commands, err := parser.Parse(dockerfile)
if err != nil {
return fmt.Errorf("unable to parse Dockerfile: %s", err)
}
if len(commands) == 0 {
return fmt.Errorf("no commands found in Dockerfile")
}
for i, command := range commands {
if err := b.dispatch(i, command); err != nil {
return err
}
}
// create container and commit if we need to (because of trailing
// metadata directives).
if b.uncommitted && !b.probeCache() {
b.containerID, err = b.createContainer([]string{"/bin/sh", "-c"}, []string{"#(nop)"}, false)
if err != nil {
return fmt.Errorf("unable to create container: %s", err)
}
if err := b.commit(); err != nil {
return fmt.Errorf("unable to commit container image: %s", err)
}
}
imageName := b.imageID
if named, hasName := b.ref.(reference.Named); hasName {
imageName = b.ref.String()
var tag string
if tagged, isTagged := named.(reference.Tagged); isTagged {
tag = tagged.Tag()
}
if err := b.setTag(b.imageID, named.Name(), tag); err != nil {
return fmt.Errorf("unable to tag built image: %s", err)
}
}
fmt.Fprintf(b.out, "Successfully built %s\n", imageName)
return nil
} | [
"func",
"(",
"b",
"*",
"Builder",
")",
"Run",
"(",
")",
"error",
"{",
"// Parse the Dockerfile.",
"dockerfile",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"b",
".",
"dockerfilePath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Err... | // Run executes the build process. | [
"Run",
"executes",
"the",
"build",
"process",
"."
] | fa026f9d0ef7a388cc8487e601adc3ab8d508551 | https://github.com/jlhawn/dockramp/blob/fa026f9d0ef7a388cc8487e601adc3ab8d508551/build/builder.go#L144-L197 |
151,081 | jlhawn/dockramp | build/builder.go | makeCommandString | func makeCommandString(cmd string, args ...string) string {
quotedArgs := make([]string, len(args))
for i, arg := range args {
if strings.ContainsAny(arg, "<#'\" \f\n\r\t\v\\") {
arg = strconv.Quote(arg)
}
quotedArgs[i] = arg
}
return fmt.Sprintf("%s %s", cmd, strings.Join(quotedArgs, " "))
} | go | func makeCommandString(cmd string, args ...string) string {
quotedArgs := make([]string, len(args))
for i, arg := range args {
if strings.ContainsAny(arg, "<#'\" \f\n\r\t\v\\") {
arg = strconv.Quote(arg)
}
quotedArgs[i] = arg
}
return fmt.Sprintf("%s %s", cmd, strings.Join(quotedArgs, " "))
} | [
"func",
"makeCommandString",
"(",
"cmd",
"string",
",",
"args",
"...",
"string",
")",
"string",
"{",
"quotedArgs",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"args",
")",
")",
"\n\n",
"for",
"i",
",",
"arg",
":=",
"range",
"args",
"{",
... | // makeCommandString returns a printable form of the command and arguments with
// arguments quoted if necessary. | [
"makeCommandString",
"returns",
"a",
"printable",
"form",
"of",
"the",
"command",
"and",
"arguments",
"with",
"arguments",
"quoted",
"if",
"necessary",
"."
] | fa026f9d0ef7a388cc8487e601adc3ab8d508551 | https://github.com/jlhawn/dockramp/blob/fa026f9d0ef7a388cc8487e601adc3ab8d508551/build/builder.go#L256-L267 |
151,082 | jwangsadinata/go-multimap | slicemultimap/slicemultimap.go | PutAll | func (m *MultiMap) PutAll(key interface{}, values []interface{}) {
for _, value := range values {
m.Put(key, value)
}
} | go | func (m *MultiMap) PutAll(key interface{}, values []interface{}) {
for _, value := range values {
m.Put(key, value)
}
} | [
"func",
"(",
"m",
"*",
"MultiMap",
")",
"PutAll",
"(",
"key",
"interface",
"{",
"}",
",",
"values",
"[",
"]",
"interface",
"{",
"}",
")",
"{",
"for",
"_",
",",
"value",
":=",
"range",
"values",
"{",
"m",
".",
"Put",
"(",
"key",
",",
"value",
")... | // PutAll stores a key-value pair in this multimap for each of the values, all using the same key key. | [
"PutAll",
"stores",
"a",
"key",
"-",
"value",
"pair",
"in",
"this",
"multimap",
"for",
"each",
"of",
"the",
"values",
"all",
"using",
"the",
"same",
"key",
"key",
"."
] | 599609688a40c0234f4ed5bdc005b241909dbc46 | https://github.com/jwangsadinata/go-multimap/blob/599609688a40c0234f4ed5bdc005b241909dbc46/slicemultimap/slicemultimap.go#L40-L44 |
151,083 | jwangsadinata/go-multimap | slicemultimap/slicemultimap.go | ContainsKey | func (m *MultiMap) ContainsKey(key interface{}) (found bool) {
_, found = m.m[key]
return
} | go | func (m *MultiMap) ContainsKey(key interface{}) (found bool) {
_, found = m.m[key]
return
} | [
"func",
"(",
"m",
"*",
"MultiMap",
")",
"ContainsKey",
"(",
"key",
"interface",
"{",
"}",
")",
"(",
"found",
"bool",
")",
"{",
"_",
",",
"found",
"=",
"m",
".",
"m",
"[",
"key",
"]",
"\n",
"return",
"\n",
"}"
] | // ContainsKey returns true if this multimap contains at least one key-value pair with the key key. | [
"ContainsKey",
"returns",
"true",
"if",
"this",
"multimap",
"contains",
"at",
"least",
"one",
"key",
"-",
"value",
"pair",
"with",
"the",
"key",
"key",
"."
] | 599609688a40c0234f4ed5bdc005b241909dbc46 | https://github.com/jwangsadinata/go-multimap/blob/599609688a40c0234f4ed5bdc005b241909dbc46/slicemultimap/slicemultimap.go#L58-L61 |
151,084 | jwangsadinata/go-multimap | slicemultimap/slicemultimap.go | Keys | func (m *MultiMap) Keys() []interface{} {
keys := make([]interface{}, m.Size())
count := 0
for key, value := range m.m {
for range value {
keys[count] = key
count++
}
}
return keys
} | go | func (m *MultiMap) Keys() []interface{} {
keys := make([]interface{}, m.Size())
count := 0
for key, value := range m.m {
for range value {
keys[count] = key
count++
}
}
return keys
} | [
"func",
"(",
"m",
"*",
"MultiMap",
")",
"Keys",
"(",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"keys",
":=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"m",
".",
"Size",
"(",
")",
")",
"\n",
"count",
":=",
"0",
"\n",
"for",
"key",
... | // Keys returns a view collection containing the key from each key-value pair in this multimap.
// This is done without collapsing duplicates. | [
"Keys",
"returns",
"a",
"view",
"collection",
"containing",
"the",
"key",
"from",
"each",
"key",
"-",
"value",
"pair",
"in",
"this",
"multimap",
".",
"This",
"is",
"done",
"without",
"collapsing",
"duplicates",
"."
] | 599609688a40c0234f4ed5bdc005b241909dbc46 | https://github.com/jwangsadinata/go-multimap/blob/599609688a40c0234f4ed5bdc005b241909dbc46/slicemultimap/slicemultimap.go#L111-L121 |
151,085 | jwangsadinata/go-multimap | slicemultimap/slicemultimap.go | KeySet | func (m *MultiMap) KeySet() []interface{} {
keys := make([]interface{}, len(m.m))
count := 0
for key := range m.m {
keys[count] = key
count++
}
return keys
} | go | func (m *MultiMap) KeySet() []interface{} {
keys := make([]interface{}, len(m.m))
count := 0
for key := range m.m {
keys[count] = key
count++
}
return keys
} | [
"func",
"(",
"m",
"*",
"MultiMap",
")",
"KeySet",
"(",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"keys",
":=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"len",
"(",
"m",
".",
"m",
")",
")",
"\n",
"count",
":=",
"0",
"\n",
"for",
"... | // KeySet returns all distinct keys contained in this multimap. | [
"KeySet",
"returns",
"all",
"distinct",
"keys",
"contained",
"in",
"this",
"multimap",
"."
] | 599609688a40c0234f4ed5bdc005b241909dbc46 | https://github.com/jwangsadinata/go-multimap/blob/599609688a40c0234f4ed5bdc005b241909dbc46/slicemultimap/slicemultimap.go#L124-L132 |
151,086 | jlhawn/dockramp | archive/copy.go | HasTrailingPathSeparator | func HasTrailingPathSeparator(path string) bool {
return len(path) > 0 && os.IsPathSeparator(path[len(path)-1])
} | go | func HasTrailingPathSeparator(path string) bool {
return len(path) > 0 && os.IsPathSeparator(path[len(path)-1])
} | [
"func",
"HasTrailingPathSeparator",
"(",
"path",
"string",
")",
"bool",
"{",
"return",
"len",
"(",
"path",
")",
">",
"0",
"&&",
"os",
".",
"IsPathSeparator",
"(",
"path",
"[",
"len",
"(",
"path",
")",
"-",
"1",
"]",
")",
"\n",
"}"
] | // HasTrailingPathSeparator returns whether the given
// path ends with the system's path separator character. | [
"HasTrailingPathSeparator",
"returns",
"whether",
"the",
"given",
"path",
"ends",
"with",
"the",
"system",
"s",
"path",
"separator",
"character",
"."
] | fa026f9d0ef7a388cc8487e601adc3ab8d508551 | https://github.com/jlhawn/dockramp/blob/fa026f9d0ef7a388cc8487e601adc3ab8d508551/archive/copy.go#L57-L59 |
151,087 | jlhawn/dockramp | archive/copy.go | SplitPathDirEntry | func SplitPathDirEntry(localizedPath string) (dir, base string) {
normalizedPath := filepath.ToSlash(localizedPath)
vol := filepath.VolumeName(normalizedPath)
normalizedPath = normalizedPath[len(vol):]
if normalizedPath == "/" {
// Specifies the root path.
return filepath.FromSlash(vol + normalizedPath), "."
}
trimmedPath := vol + strings.TrimRight(normalizedPath, "/")
dir = filepath.FromSlash(path.Dir(trimmedPath))
base = filepath.FromSlash(path.Base(trimmedPath))
return dir, base
} | go | func SplitPathDirEntry(localizedPath string) (dir, base string) {
normalizedPath := filepath.ToSlash(localizedPath)
vol := filepath.VolumeName(normalizedPath)
normalizedPath = normalizedPath[len(vol):]
if normalizedPath == "/" {
// Specifies the root path.
return filepath.FromSlash(vol + normalizedPath), "."
}
trimmedPath := vol + strings.TrimRight(normalizedPath, "/")
dir = filepath.FromSlash(path.Dir(trimmedPath))
base = filepath.FromSlash(path.Base(trimmedPath))
return dir, base
} | [
"func",
"SplitPathDirEntry",
"(",
"localizedPath",
"string",
")",
"(",
"dir",
",",
"base",
"string",
")",
"{",
"normalizedPath",
":=",
"filepath",
".",
"ToSlash",
"(",
"localizedPath",
")",
"\n",
"vol",
":=",
"filepath",
".",
"VolumeName",
"(",
"normalizedPath... | // SplitPathDirEntry splits the given path between its
// parent directory and its basename in that directory. | [
"SplitPathDirEntry",
"splits",
"the",
"given",
"path",
"between",
"its",
"parent",
"directory",
"and",
"its",
"basename",
"in",
"that",
"directory",
"."
] | fa026f9d0ef7a388cc8487e601adc3ab8d508551 | https://github.com/jlhawn/dockramp/blob/fa026f9d0ef7a388cc8487e601adc3ab8d508551/archive/copy.go#L69-L85 |
151,088 | jlhawn/dockramp | archive/copy.go | TarResource | func TarResource(sourcePath string) (content Archive, err error) {
if _, err = os.Lstat(sourcePath); err != nil {
// Catches the case where the source does not exist or is not a
// directory if asserted to be a directory, as this also causes an
// error.
return
}
if len(sourcePath) > 1 && HasTrailingPathSeparator(sourcePath) {
// In the case where the source path is a symbolic link AND it ends
// with a path separator, we will want to evaluate the symbolic link.
trimmedPath := sourcePath[:len(sourcePath)-1]
stat, err := os.Lstat(trimmedPath)
if err != nil {
return nil, err
}
if stat.Mode()&os.ModeSymlink != 0 {
if sourcePath, err = filepath.EvalSymlinks(trimmedPath); err != nil {
return nil, err
}
}
}
// Separate the source path between it's directory and
// the entry in that directory which we are archiving.
sourceDir, sourceBase := SplitPathDirEntry(sourcePath)
filter := []string{sourceBase}
log.Debugf("copying %q from %q", sourceBase, sourceDir)
return TarWithOptions(sourceDir, &TarOptions{
IncludeFiles: filter,
IncludeSourceDir: true,
})
} | go | func TarResource(sourcePath string) (content Archive, err error) {
if _, err = os.Lstat(sourcePath); err != nil {
// Catches the case where the source does not exist or is not a
// directory if asserted to be a directory, as this also causes an
// error.
return
}
if len(sourcePath) > 1 && HasTrailingPathSeparator(sourcePath) {
// In the case where the source path is a symbolic link AND it ends
// with a path separator, we will want to evaluate the symbolic link.
trimmedPath := sourcePath[:len(sourcePath)-1]
stat, err := os.Lstat(trimmedPath)
if err != nil {
return nil, err
}
if stat.Mode()&os.ModeSymlink != 0 {
if sourcePath, err = filepath.EvalSymlinks(trimmedPath); err != nil {
return nil, err
}
}
}
// Separate the source path between it's directory and
// the entry in that directory which we are archiving.
sourceDir, sourceBase := SplitPathDirEntry(sourcePath)
filter := []string{sourceBase}
log.Debugf("copying %q from %q", sourceBase, sourceDir)
return TarWithOptions(sourceDir, &TarOptions{
IncludeFiles: filter,
IncludeSourceDir: true,
})
} | [
"func",
"TarResource",
"(",
"sourcePath",
"string",
")",
"(",
"content",
"Archive",
",",
"err",
"error",
")",
"{",
"if",
"_",
",",
"err",
"=",
"os",
".",
"Lstat",
"(",
"sourcePath",
")",
";",
"err",
"!=",
"nil",
"{",
"// Catches the case where the source d... | // TarResource archives the resource at the given sourcePath into a Tar
// archive. A non-nil error is returned if sourcePath does not exist or is
// asserted to be a directory but exists as another type of file.
//
// This function acts as a convenient wrapper around TarWithOptions, which
// requires a directory as the source path. TarResource accepts either a
// directory or a file path and correctly sets the Tar options. | [
"TarResource",
"archives",
"the",
"resource",
"at",
"the",
"given",
"sourcePath",
"into",
"a",
"Tar",
"archive",
".",
"A",
"non",
"-",
"nil",
"error",
"is",
"returned",
"if",
"sourcePath",
"does",
"not",
"exist",
"or",
"is",
"asserted",
"to",
"be",
"a",
... | fa026f9d0ef7a388cc8487e601adc3ab8d508551 | https://github.com/jlhawn/dockramp/blob/fa026f9d0ef7a388cc8487e601adc3ab8d508551/archive/copy.go#L94-L130 |
151,089 | jlhawn/dockramp | archive/copy.go | CopyInfoStatPath | func CopyInfoStatPath(path string, mustExist bool) (CopyInfo, error) {
pathInfo := CopyInfo{Path: path}
fileInfo, err := os.Lstat(path)
if err == nil {
pathInfo.Exists, pathInfo.IsDir = true, fileInfo.IsDir()
} else if os.IsNotExist(err) && !mustExist {
err = nil
}
return pathInfo, err
} | go | func CopyInfoStatPath(path string, mustExist bool) (CopyInfo, error) {
pathInfo := CopyInfo{Path: path}
fileInfo, err := os.Lstat(path)
if err == nil {
pathInfo.Exists, pathInfo.IsDir = true, fileInfo.IsDir()
} else if os.IsNotExist(err) && !mustExist {
err = nil
}
return pathInfo, err
} | [
"func",
"CopyInfoStatPath",
"(",
"path",
"string",
",",
"mustExist",
"bool",
")",
"(",
"CopyInfo",
",",
"error",
")",
"{",
"pathInfo",
":=",
"CopyInfo",
"{",
"Path",
":",
"path",
"}",
"\n\n",
"fileInfo",
",",
"err",
":=",
"os",
".",
"Lstat",
"(",
"path... | // CopyInfoStatPath stats the given path to create a CopyInfo
// struct representing that resource. If mustExist is true, then
// it is an error if there is no file or directory at the given path. | [
"CopyInfoStatPath",
"stats",
"the",
"given",
"path",
"to",
"create",
"a",
"CopyInfo",
"struct",
"representing",
"that",
"resource",
".",
"If",
"mustExist",
"is",
"true",
"then",
"it",
"is",
"an",
"error",
"if",
"there",
"is",
"no",
"file",
"or",
"directory",... | fa026f9d0ef7a388cc8487e601adc3ab8d508551 | https://github.com/jlhawn/dockramp/blob/fa026f9d0ef7a388cc8487e601adc3ab8d508551/archive/copy.go#L143-L155 |
151,090 | jlhawn/dockramp | build/parser/parser.go | Parse | func Parse(input io.Reader) (commands []*Command, err error) {
scanner := bufio.NewScanner(input)
var currentToken token
scanner.Split(tokenize(¤tToken))
var tokens []token
for scanner.Scan() {
tokens = append(tokens, currentToken)
if numTokens := len(tokens); numTokens > 1 {
prevToken := tokens[numTokens-2]
if mergedToken := prevToken.Merge(currentToken); mergedToken != nil {
tokens[numTokens-2] = mergedToken
tokens = tokens[:numTokens-1]
}
}
}
if err := scanner.Err(); err != nil {
return nil, err
}
beginning := true
var currentCommand *Command
for _, token := range tokens {
if token.Type() == tokenTypeWhitespace {
continue // Ignore whitespace tokens.
}
if token.Type() == tokenTypeNewline {
if !beginning { // handle leading newlines.
// Newline signals the end of a command.
commands = append(commands, currentCommand)
currentCommand = nil
}
continue
}
if token.Type() == tokenTypeHeredoc {
if currentCommand == nil {
return nil, errors.New("unexpected heredoc")
}
currentCommand.Heredoc = token.Value()
// Heredoc also signals the end of a command.
commands = append(commands, currentCommand)
currentCommand = nil
continue
}
if token.Type() != tokenTypeArg {
return nil, errors.New("unexpected token")
}
beginning = false
// Append arg to current command.
if currentCommand == nil {
currentCommand = &Command{}
}
currentCommand.Args = append(currentCommand.Args, token.Value())
}
if currentCommand != nil {
// Handles case with no trailing newline.
commands = append(commands, currentCommand)
}
return commands, nil
} | go | func Parse(input io.Reader) (commands []*Command, err error) {
scanner := bufio.NewScanner(input)
var currentToken token
scanner.Split(tokenize(¤tToken))
var tokens []token
for scanner.Scan() {
tokens = append(tokens, currentToken)
if numTokens := len(tokens); numTokens > 1 {
prevToken := tokens[numTokens-2]
if mergedToken := prevToken.Merge(currentToken); mergedToken != nil {
tokens[numTokens-2] = mergedToken
tokens = tokens[:numTokens-1]
}
}
}
if err := scanner.Err(); err != nil {
return nil, err
}
beginning := true
var currentCommand *Command
for _, token := range tokens {
if token.Type() == tokenTypeWhitespace {
continue // Ignore whitespace tokens.
}
if token.Type() == tokenTypeNewline {
if !beginning { // handle leading newlines.
// Newline signals the end of a command.
commands = append(commands, currentCommand)
currentCommand = nil
}
continue
}
if token.Type() == tokenTypeHeredoc {
if currentCommand == nil {
return nil, errors.New("unexpected heredoc")
}
currentCommand.Heredoc = token.Value()
// Heredoc also signals the end of a command.
commands = append(commands, currentCommand)
currentCommand = nil
continue
}
if token.Type() != tokenTypeArg {
return nil, errors.New("unexpected token")
}
beginning = false
// Append arg to current command.
if currentCommand == nil {
currentCommand = &Command{}
}
currentCommand.Args = append(currentCommand.Args, token.Value())
}
if currentCommand != nil {
// Handles case with no trailing newline.
commands = append(commands, currentCommand)
}
return commands, nil
} | [
"func",
"Parse",
"(",
"input",
"io",
".",
"Reader",
")",
"(",
"commands",
"[",
"]",
"*",
"Command",
",",
"err",
"error",
")",
"{",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"input",
")",
"\n\n",
"var",
"currentToken",
"token",
"\n",
"scanner",
... | // Parse parses the given input as a line-separated list of arguments.
// On success, a slice of argument lists is returned. | [
"Parse",
"parses",
"the",
"given",
"input",
"as",
"a",
"line",
"-",
"separated",
"list",
"of",
"arguments",
".",
"On",
"success",
"a",
"slice",
"of",
"argument",
"lists",
"is",
"returned",
"."
] | fa026f9d0ef7a388cc8487e601adc3ab8d508551 | https://github.com/jlhawn/dockramp/blob/fa026f9d0ef7a388cc8487e601adc3ab8d508551/build/parser/parser.go#L17-L88 |
151,091 | brutella/dnssd | probe.go | ProbeService | func ProbeService(ctx context.Context, srv Service) (Service, error) {
conn, err := newMDNSConn()
if err != nil {
return srv, err
}
defer conn.close()
// After one minute of probing, if the Multicast DNS responder has been
// unable to find any unused name, it should log an error (RFC6762 9)
probeCtx, cancel := context.WithTimeout(ctx, 60*time.Second)
defer cancel()
// When ready to send its Multicast DNS probe packet(s) the host should
// first wait for a short random delay time, uniformly distributed in
// the range 0-250 ms. (RFC6762 8.1)
r := rand.New(rand.NewSource(time.Now().UnixNano()))
delay := time.Duration(r.Intn(250)) * time.Millisecond
log.Debug.Println("Probing delay", delay)
time.Sleep(delay)
return probeService(probeCtx, conn, srv, 1*time.Millisecond, false)
} | go | func ProbeService(ctx context.Context, srv Service) (Service, error) {
conn, err := newMDNSConn()
if err != nil {
return srv, err
}
defer conn.close()
// After one minute of probing, if the Multicast DNS responder has been
// unable to find any unused name, it should log an error (RFC6762 9)
probeCtx, cancel := context.WithTimeout(ctx, 60*time.Second)
defer cancel()
// When ready to send its Multicast DNS probe packet(s) the host should
// first wait for a short random delay time, uniformly distributed in
// the range 0-250 ms. (RFC6762 8.1)
r := rand.New(rand.NewSource(time.Now().UnixNano()))
delay := time.Duration(r.Intn(250)) * time.Millisecond
log.Debug.Println("Probing delay", delay)
time.Sleep(delay)
return probeService(probeCtx, conn, srv, 1*time.Millisecond, false)
} | [
"func",
"ProbeService",
"(",
"ctx",
"context",
".",
"Context",
",",
"srv",
"Service",
")",
"(",
"Service",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"newMDNSConn",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"srv",
",",
"err",
... | // ProbeService probes for the hostname and service instance name of srv.
// If err == nil, the returned service is verified to be unique on the local network. | [
"ProbeService",
"probes",
"for",
"the",
"hostname",
"and",
"service",
"instance",
"name",
"of",
"srv",
".",
"If",
"err",
"==",
"nil",
"the",
"returned",
"service",
"is",
"verified",
"to",
"be",
"unique",
"on",
"the",
"local",
"network",
"."
] | 61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0 | https://github.com/brutella/dnssd/blob/61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0/probe.go#L16-L39 |
151,092 | brutella/dnssd | probe.go | isDenyingAAAA | func isDenyingAAAA(this *dns.AAAA, that *dns.AAAA) bool {
if strings.EqualFold(this.Hdr.Name, that.Hdr.Name) {
log.Debug.Println("Conflicting hosts")
if !isValidRR(this) {
log.Debug.Println("Invalid record produces conflict")
return true
}
switch compareIP(this.AAAA.To16(), that.AAAA.To16()) {
case -1:
log.Debug.Println("Lexicographical earlier")
break
case 1:
log.Debug.Println("Lexicographical later")
return true
default:
log.Debug.Println("Tiebreak")
break
}
}
return false
} | go | func isDenyingAAAA(this *dns.AAAA, that *dns.AAAA) bool {
if strings.EqualFold(this.Hdr.Name, that.Hdr.Name) {
log.Debug.Println("Conflicting hosts")
if !isValidRR(this) {
log.Debug.Println("Invalid record produces conflict")
return true
}
switch compareIP(this.AAAA.To16(), that.AAAA.To16()) {
case -1:
log.Debug.Println("Lexicographical earlier")
break
case 1:
log.Debug.Println("Lexicographical later")
return true
default:
log.Debug.Println("Tiebreak")
break
}
}
return false
} | [
"func",
"isDenyingAAAA",
"(",
"this",
"*",
"dns",
".",
"AAAA",
",",
"that",
"*",
"dns",
".",
"AAAA",
")",
"bool",
"{",
"if",
"strings",
".",
"EqualFold",
"(",
"this",
".",
"Hdr",
".",
"Name",
",",
"that",
".",
"Hdr",
".",
"Name",
")",
"{",
"log",... | // isDenyingAAAA returns true if this denies that. | [
"isDenyingAAAA",
"returns",
"true",
"if",
"this",
"denies",
"that",
"."
] | 61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0 | https://github.com/brutella/dnssd/blob/61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0/probe.go#L271-L293 |
151,093 | brutella/dnssd | probe.go | isDenyingSRV | func isDenyingSRV(this *dns.SRV, that *dns.SRV) bool {
if strings.EqualFold(this.Hdr.Name, that.Hdr.Name) {
log.Debug.Println("Conflicting SRV")
if !isValidRR(this) {
log.Debug.Println("Invalid record produces conflict")
return true
}
switch compareSRV(this, that) {
case -1:
log.Debug.Println("Lexicographical earlier")
break
case 1:
log.Debug.Println("Lexicographical later")
return true
default:
log.Debug.Println("Tiebreak")
break
}
}
return false
} | go | func isDenyingSRV(this *dns.SRV, that *dns.SRV) bool {
if strings.EqualFold(this.Hdr.Name, that.Hdr.Name) {
log.Debug.Println("Conflicting SRV")
if !isValidRR(this) {
log.Debug.Println("Invalid record produces conflict")
return true
}
switch compareSRV(this, that) {
case -1:
log.Debug.Println("Lexicographical earlier")
break
case 1:
log.Debug.Println("Lexicographical later")
return true
default:
log.Debug.Println("Tiebreak")
break
}
}
return false
} | [
"func",
"isDenyingSRV",
"(",
"this",
"*",
"dns",
".",
"SRV",
",",
"that",
"*",
"dns",
".",
"SRV",
")",
"bool",
"{",
"if",
"strings",
".",
"EqualFold",
"(",
"this",
".",
"Hdr",
".",
"Name",
",",
"that",
".",
"Hdr",
".",
"Name",
")",
"{",
"log",
... | // isDenyingSRV returns true if this denies that. | [
"isDenyingSRV",
"returns",
"true",
"if",
"this",
"denies",
"that",
"."
] | 61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0 | https://github.com/brutella/dnssd/blob/61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0/probe.go#L296-L318 |
151,094 | brutella/dnssd | dns.go | includesIPv4 | func includesIPv4(ips []net.IP) bool {
for _, ip := range ips {
if ip.To4() != nil {
return true
}
}
return false
} | go | func includesIPv4(ips []net.IP) bool {
for _, ip := range ips {
if ip.To4() != nil {
return true
}
}
return false
} | [
"func",
"includesIPv4",
"(",
"ips",
"[",
"]",
"net",
".",
"IP",
")",
"bool",
"{",
"for",
"_",
",",
"ip",
":=",
"range",
"ips",
"{",
"if",
"ip",
".",
"To4",
"(",
")",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
... | // Returns true if ips contains IPv4 addresses. | [
"Returns",
"true",
"if",
"ips",
"contains",
"IPv4",
"addresses",
"."
] | 61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0 | https://github.com/brutella/dnssd/blob/61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0/dns.go#L168-L176 |
151,095 | brutella/dnssd | dns.go | includesIPv6 | func includesIPv6(ips []net.IP) bool {
for _, ip := range ips {
if ip.To4() == nil && ip.To16() != nil {
return true
}
}
return false
} | go | func includesIPv6(ips []net.IP) bool {
for _, ip := range ips {
if ip.To4() == nil && ip.To16() != nil {
return true
}
}
return false
} | [
"func",
"includesIPv6",
"(",
"ips",
"[",
"]",
"net",
".",
"IP",
")",
"bool",
"{",
"for",
"_",
",",
"ip",
":=",
"range",
"ips",
"{",
"if",
"ip",
".",
"To4",
"(",
")",
"==",
"nil",
"&&",
"ip",
".",
"To16",
"(",
")",
"!=",
"nil",
"{",
"return",
... | // Returns true if ips contains IPv6 addresses. | [
"Returns",
"true",
"if",
"ips",
"contains",
"IPv6",
"addresses",
"."
] | 61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0 | https://github.com/brutella/dnssd/blob/61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0/dns.go#L179-L187 |
151,096 | brutella/dnssd | dns.go | remove | func remove(this []dns.RR, that []dns.RR) []dns.RR {
var result []dns.RR
for _, thatRr := range that {
isUnknown := true
for _, thisRr := range this {
switch a := thisRr.(type) {
case *dns.PTR:
if ptr, ok := thatRr.(*dns.PTR); ok {
if a.Ptr == ptr.Ptr && a.Hdr.Name == ptr.Hdr.Name && a.Hdr.Ttl > ptr.Hdr.Ttl/2 {
isUnknown = false
}
}
case *dns.SRV:
if srv, ok := thatRr.(*dns.SRV); ok {
if a.Target == srv.Target && a.Port == srv.Port && a.Hdr.Name == srv.Hdr.Name && a.Hdr.Ttl > srv.Hdr.Ttl/2 {
isUnknown = false
}
}
case *dns.TXT:
if txt, ok := thatRr.(*dns.TXT); ok {
if reflect.DeepEqual(a.Txt, txt.Txt) && a.Hdr.Ttl > txt.Hdr.Ttl/2 {
isUnknown = false
}
}
}
}
if isUnknown {
result = append(result, thatRr)
}
}
return result
} | go | func remove(this []dns.RR, that []dns.RR) []dns.RR {
var result []dns.RR
for _, thatRr := range that {
isUnknown := true
for _, thisRr := range this {
switch a := thisRr.(type) {
case *dns.PTR:
if ptr, ok := thatRr.(*dns.PTR); ok {
if a.Ptr == ptr.Ptr && a.Hdr.Name == ptr.Hdr.Name && a.Hdr.Ttl > ptr.Hdr.Ttl/2 {
isUnknown = false
}
}
case *dns.SRV:
if srv, ok := thatRr.(*dns.SRV); ok {
if a.Target == srv.Target && a.Port == srv.Port && a.Hdr.Name == srv.Hdr.Name && a.Hdr.Ttl > srv.Hdr.Ttl/2 {
isUnknown = false
}
}
case *dns.TXT:
if txt, ok := thatRr.(*dns.TXT); ok {
if reflect.DeepEqual(a.Txt, txt.Txt) && a.Hdr.Ttl > txt.Hdr.Ttl/2 {
isUnknown = false
}
}
}
}
if isUnknown {
result = append(result, thatRr)
}
}
return result
} | [
"func",
"remove",
"(",
"this",
"[",
"]",
"dns",
".",
"RR",
",",
"that",
"[",
"]",
"dns",
".",
"RR",
")",
"[",
"]",
"dns",
".",
"RR",
"{",
"var",
"result",
"[",
"]",
"dns",
".",
"RR",
"\n",
"for",
"_",
",",
"thatRr",
":=",
"range",
"that",
"... | // Removes this from that. | [
"Removes",
"this",
"from",
"that",
"."
] | 61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0 | https://github.com/brutella/dnssd/blob/61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0/dns.go#L190-L223 |
151,097 | brutella/dnssd | dns.go | mergeMsgs | func mergeMsgs(msgs []*dns.Msg) *dns.Msg {
resp := new(dns.Msg)
resp.Answer = []dns.RR{}
resp.Ns = []dns.RR{}
resp.Extra = []dns.RR{}
resp.Question = []dns.Question{}
for _, msg := range msgs {
if msg.Answer != nil {
resp.Answer = append(resp.Answer, remove(resp.Answer, msg.Answer)...)
}
if msg.Ns != nil {
resp.Ns = append(resp.Ns, remove(resp.Ns, msg.Ns)...)
}
if msg.Extra != nil {
resp.Extra = append(resp.Extra, remove(resp.Extra, msg.Extra)...)
}
if msg.Question != nil {
resp.Question = append(resp.Question, msg.Question...)
}
}
return resp
} | go | func mergeMsgs(msgs []*dns.Msg) *dns.Msg {
resp := new(dns.Msg)
resp.Answer = []dns.RR{}
resp.Ns = []dns.RR{}
resp.Extra = []dns.RR{}
resp.Question = []dns.Question{}
for _, msg := range msgs {
if msg.Answer != nil {
resp.Answer = append(resp.Answer, remove(resp.Answer, msg.Answer)...)
}
if msg.Ns != nil {
resp.Ns = append(resp.Ns, remove(resp.Ns, msg.Ns)...)
}
if msg.Extra != nil {
resp.Extra = append(resp.Extra, remove(resp.Extra, msg.Extra)...)
}
if msg.Question != nil {
resp.Question = append(resp.Question, msg.Question...)
}
}
return resp
} | [
"func",
"mergeMsgs",
"(",
"msgs",
"[",
"]",
"*",
"dns",
".",
"Msg",
")",
"*",
"dns",
".",
"Msg",
"{",
"resp",
":=",
"new",
"(",
"dns",
".",
"Msg",
")",
"\n",
"resp",
".",
"Answer",
"=",
"[",
"]",
"dns",
".",
"RR",
"{",
"}",
"\n",
"resp",
".... | // mergeMsgs merges the records in msgs into one message. | [
"mergeMsgs",
"merges",
"the",
"records",
"in",
"msgs",
"into",
"one",
"message",
"."
] | 61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0 | https://github.com/brutella/dnssd/blob/61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0/dns.go#L226-L250 |
151,098 | brutella/dnssd | service.go | IPsAtInterface | func (s *Service) IPsAtInterface(iface *net.Interface) []net.IP {
if ips := s.IfaceIPs[iface.Name]; ips != nil {
return ips
}
return []net.IP{}
} | go | func (s *Service) IPsAtInterface(iface *net.Interface) []net.IP {
if ips := s.IfaceIPs[iface.Name]; ips != nil {
return ips
}
return []net.IP{}
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"IPsAtInterface",
"(",
"iface",
"*",
"net",
".",
"Interface",
")",
"[",
"]",
"net",
".",
"IP",
"{",
"if",
"ips",
":=",
"s",
".",
"IfaceIPs",
"[",
"iface",
".",
"Name",
"]",
";",
"ips",
"!=",
"nil",
"{",
"r... | // IPsAtInterface returns the ip address at a specific interface. | [
"IPsAtInterface",
"returns",
"the",
"ip",
"address",
"at",
"a",
"specific",
"interface",
"."
] | 61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0 | https://github.com/brutella/dnssd/blob/61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0/service.go#L140-L146 |
151,099 | brutella/dnssd | service.go | hostname | func hostname() string {
hostname, err := os.Hostname()
if err != nil {
return "unknown"
}
name, _ := parseHostname(hostname)
return sanitizeHostname(name)
} | go | func hostname() string {
hostname, err := os.Hostname()
if err != nil {
return "unknown"
}
name, _ := parseHostname(hostname)
return sanitizeHostname(name)
} | [
"func",
"hostname",
"(",
")",
"string",
"{",
"hostname",
",",
"err",
":=",
"os",
".",
"Hostname",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"name",
",",
"_",
":=",
"parseHostname",
"(",
"hostname",
")",... | // Get Fully Qualified Domain Name
// returns "unknown" or hostanme in case of error | [
"Get",
"Fully",
"Qualified",
"Domain",
"Name",
"returns",
"unknown",
"or",
"hostanme",
"in",
"case",
"of",
"error"
] | 61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0 | https://github.com/brutella/dnssd/blob/61d1bc6e53ace5b3d9ecb46ffd0b3158c00ae9d0/service.go#L214-L222 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.