Dave
Dave

Reputation: 8937

Grails URL Mapping question

I'm using Grails 1.2.1. I want to set up this mapping ...

http://localhost:8080/context-path/mediaproxy

So I added this to my URLMappings.groovy file ...

class UrlMappings {
    static mappings = {
      ‰name mediaproxy: "/mediaproxy" {
          controller = "SocialMediaCacheProxy"
          action = "index"
      }
      "/"(view:"/index")
      "500"(view:'/error')
    }

}

However, I'm getting a 404 when I visit the above URL. Here is how I set up my controller

class SocialMediaCacheProxyController {

    def index = {
        if (params.dumpAll != null) {

        } else if (params.url != null) {
            doCacheTransport(params, response); 
        }   // if
    }

...
}

Any ideas what I'm doing wrong? Thanks, - Dave

Upvotes: 0

Views: 617

Answers (2)

stefanglase
stefanglase

Reputation: 10402

There are is some weird character in front of your named mapping (‰) and your controller name should be lowercase on the first character so that it points to SocialMediaCacheProxyController.

If you don't need a named mapping the following mapping would do the trick for you:

class UrlMappings {
    static mappings = {
        "/mediaproxy"(controller:"socialMediaCacheProxy", action:"index")
        "/"(view:"/index")
        "500"(view:'/error')
    }
}

Upvotes: 2

mfloryan
mfloryan

Reputation: 7685

It might be some problem with your question formatting but I would expect the url mapping to look like this:

class UrlMappings {
    static mappings = {
      "/mediaproxy" {
          controller = "SocialMediaCacheProxy"
          action = "index"
      }
      "/"(view:"/index")
      "500"(view:'/error')
    }
}

Upvotes: 0

Related Questions