diff --git a/config/controller.go b/config/controller.go index 56cfc16..fd1df86 100644 --- a/config/controller.go +++ b/config/controller.go @@ -210,8 +210,8 @@ func (c *Controller) format(controllerName string) error { for ctlName, ctl := range c.Children { /* (3) Invalid name */ - if strings.Contains(ctlName, "/") { - return fmt.Errorf("Controller '%s' must not contain any slash '/'", ctlName) + if strings.ContainsAny(ctlName, "/-") { + return fmt.Errorf("Controller '%s' must not contain any slash '/' nor '-' symbols", ctlName) } /* (4) Check recursively */ diff --git a/request/request.go b/request/request.go index 1ffef65..26e8eb4 100644 --- a/request/request.go +++ b/request/request.go @@ -96,7 +96,12 @@ func FetchFormData(req *http.Request) map[string]interface{} { func (i *Request) LoadController(method string) (func(implement.Arguments, *implement.Response) implement.Response, error) { /* (1) Build controller path */ - path := fmt.Sprintf(".build/controller/%s/i.so", strings.Join(i.Path, "/")) + path := strings.Join(i.Path, "-") + if len(path) == 0 { + path = fmt.Sprintf(".build/controller/ROOT/main.so") + } else { + path = fmt.Sprintf(".build/controller/%s/main.so", path) + } /* (2) Format url */ tmp := []byte(strings.ToLower(method))