Merge branch 'x/gorm' into x/sqlx

r/paopao-ce-plus
Michael Li 1 year ago
commit ac65635f90
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`
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:], '/')
if idx < 0 {
return

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

Loading…
Cancel
Save