Skip to content

UrlMappings with group and resource produce URLs with double /'s #10210

@erichelgeson

Description

@erichelgeson

Expected Behaviour

I would expect these two mappings to be equivalent:

static mappings = {
    group "/api", {
        group "/v1", {
            "/books" resources:"book"
        }
    }
}
static mappings = {
    group "/api", {
        group "/v1", {
            group "/books", {
                "/" resources:"book"
            }
        }
    }
}

Actual Behaviour

The second produces an extra / char in the URL and can not be routed to.

$ grails url-mappings-report
...

Controller: book
 |   GET    | /api/v1/books//create             | Action: create                |
 |   GET    | /api/v1/books//${id}/edit         | Action: edit                  |
 |   POST   | /api/v1/books/                    | Action: save                  |
 |   GET    | /api/v1/books/                    | Action: index                 |
 |  DELETE  | /api/v1/books//${id}              | Action: delete                |
 |  PATCH   | /api/v1/books//${id}              | Action: patch                 |
 |   PUT    | /api/v1/books//${id}              | Action: update                |
 |   GET    | /api/v1/books//${id}              | Action: show                  |

Looking closer this may be "expected" as I did define a route "/" - though this limits the way group can be used with resources.

It would be handy to group resources like this (if you have the standard RestfulController + custom actions.)

Environment Information

  • Operating System: Mac 10.11
  • Grails Version: 3.1.12
  • JDK Version: 1.8

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions