controller name cannot contain '-', plugin packages are in 'controller/plugin-path-dash-separated/main.go' + root is '/controller/ROOT/main.go'

This commit is contained in:
Adrien Marquès 2018-07-08 11:30:53 +02:00
parent 9808dd6de4
commit e5f7cf1147
2 changed files with 8 additions and 3 deletions

View File

@ -210,8 +210,8 @@ func (c *Controller) format(controllerName string) error {
for ctlName, ctl := range c.Children { for ctlName, ctl := range c.Children {
/* (3) Invalid name */ /* (3) Invalid name */
if strings.Contains(ctlName, "/") { if strings.ContainsAny(ctlName, "/-") {
return fmt.Errorf("Controller '%s' must not contain any slash '/'", ctlName) return fmt.Errorf("Controller '%s' must not contain any slash '/' nor '-' symbols", ctlName)
} }
/* (4) Check recursively */ /* (4) Check recursively */

View File

@ -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) { func (i *Request) LoadController(method string) (func(implement.Arguments, *implement.Response) implement.Response, error) {
/* (1) Build controller path */ /* (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 */ /* (2) Format url */
tmp := []byte(strings.ToLower(method)) tmp := []byte(strings.ToLower(method))