Use Foo.Call on /foo (#1286)

Co-authored-by: Jake Sanders <i@am.so-aweso.me>
This commit is contained in:
Asim Aslam 2020-03-03 16:47:15 +00:00 committed by GitHub
parent beb5e80e87
commit 49ffc60afb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,11 @@ func apiRoute(p string) (string, string) {
p = strings.TrimPrefix(p, "/") p = strings.TrimPrefix(p, "/")
parts := strings.Split(p, "/") parts := strings.Split(p, "/")
// if we have 1 part assume name Name.Call
if len(parts) == 1 && len(parts[0]) > 0 {
return parts[0], methodName(append(parts, "Call"))
}
// If we've got two or less parts // If we've got two or less parts
// Use first part as service // Use first part as service
// Use all parts as method // Use all parts as method