统一sourceid格式

This commit is contained in:
yangjiechina
2024-06-04 20:16:10 +08:00
parent d62b3294ec
commit de6ff69f15
6 changed files with 133 additions and 81 deletions

View File

@@ -70,9 +70,14 @@ func (h handler) Process(session *session, method string, url_ *url.URL, headers
return fmt.Errorf("please establish a session first")
}
var err error
split := strings.Split(url_.Path, "/")
source := split[len(split)-1]
source := strings.TrimSpace(url_.Path)
if strings.HasPrefix(source, "/") {
source = source[1:]
}
if len(strings.TrimSpace(source)) == 0 {
return fmt.Errorf("the request source cannot be empty")
}
//反射调用各个处理函数
results := m.Call([]reflect.Value{
@@ -80,7 +85,7 @@ func (h handler) Process(session *session, method string, url_ *url.URL, headers
reflect.ValueOf(Request{session, source, method, url_, headers}),
})
err, _ = results[2].Interface().(error)
err, _ := results[2].Interface().(error)
if err != nil {
return err
}