André Peregrina
André Peregrina

Reputation: 313

Grails url mapping doing wrong action call

I'm trying to call the index action and keep calling the count action and i don't know why. This is the code in the urlmapping

group "/api/product",{
    "?"(controller: 'product', action: 'save', method: 'POST')
    "?"(controller: 'product', action: 'index', method: 'GET')
    "/$id?"(controller: 'product', action: 'delete', method: 'DELETE')
    "/$id?"(controller: 'product', action: 'update', method: 'PUT')
    "/$id?"(controller: 'product', action: 'show', method: 'GET')
    "/count?"(controller: 'product', action: 'count', method: 'GET')
}

Upvotes: 0

Views: 583

Answers (1)

Nick Hammond
Nick Hammond

Reputation: 323

Try the following mappings:

"/api/product/count"(controller:"product")
{
     action = [GET:"count"]
}

"/api/product/$id"( controller:"product")
{
     action = [GET: "show", PUT:"update",DELETE:"delete"]
}

"/api/product"( controller:"product")
{
     action = [GET: "index", POST:"save"]
}

Upvotes: 1

Related Questions