Example #1
0
File: server.go Project: tj/go-hpc
// Method parses the service name and method from the request url.
func (c *codecRequest) Method() (string, error) {
	p := strings.Split(c.r.URL.Path, "/")

	if len(p) < 2 {
		return "", ErrServiceMissing
	}

	if len(p) < 3 {
		return "", ErrMethodMissing
	}

	service := nameconv.UnderscoreToCamelcase(p[1], true)
	method := nameconv.UnderscoreToCamelcase(p[2], true)
	s := fmt.Sprintf("%s.%s", service, method)
	return s, nil
}
Example #2
0
// Lookup method by `name`.
func (g *Gateway) Lookup(name string) *reflect.Method {
	cname := nameconv.UnderscoreToCamelcase(name, true)
	return g.methods[cname]
}