Merge branch 'dev' into x/gorm

pull/351/head
Michael Li 1 year ago
commit 024d3e65fa
No known key found for this signature in database

@ -66,7 +66,11 @@ func (m *prefixMuxMap[T]) get(path string) (val T, exist bool) {
// match assume pattern like `/core.v1.AuthenticateService/login` // match assume pattern like `/core.v1.AuthenticateService/login`
func (m *prefixMuxMap[T]) match(pattern string) (val T, exist bool) { func (m *prefixMuxMap[T]) match(pattern string) (val T, exist bool) {
path, _ := strings.CutPrefix(pattern, m.prefix) path, found := strings.CutPrefix(pattern, m.prefix)
if !found {
exist = false
return
}
idx := strings.IndexByte(path[1:], '/') idx := strings.IndexByte(path[1:], '/')
if idx < 0 { if idx < 0 {
return return

@ -66,5 +66,8 @@ var _ = g.Describe("Mux", g.Ordered, func() {
val, exist = pmm.match("/connect/core.v1.AuthenticateService/logout") val, exist = pmm.match("/connect/core.v1.AuthenticateService/logout")
m.Expect(val).To(m.Equal(1)) m.Expect(val).To(m.Equal(1))
m.Expect(exist).To(m.BeTrue()) m.Expect(exist).To(m.BeTrue())
_, exist = pmm.match("/core.v1.AuthenticateService/logout")
m.Expect(exist).To(m.BeFalse())
}) })
}) })

Loading…
Cancel
Save