Grails 2.5 static files with selected content-type

30 Views Asked by At

I would like to add static file /.well-known/apple-app-site-association to the project. But I also need to set a response header connected to this file with Content-Type: application/pkcs7-mime. What is the best solution?

1

There are 1 best solutions below

0
user3783780 On

One solution is to change UrlMappings.groovy

"/.well-known/apple-app-site-association"(controller: "appleApp", action: "appleAppSiteAssociation")

and then creating AppAppController with following code

ResourceLocator grailsResourceLocator

def appleAppSiteAssociation() {
    Resource resource = grailsResourceLocator.findResourceForURI('.well-known/apple-app-site-association')
    InputStream inputStream = resource.inputStream
    response.contentType = "application/pkcs7-mime"
    response.outputStream << inputStream
    response.outputStream.flush()
}