Idle ramblings

Tuesday, September 28, 2010

Adding application version as a response header in grails

Using a filter, eg: grails-app/conf/HeaderFilters.groovy

class HeaderFilters {
  def grailsApplication
  def filters = {
    versionFilter(uri:'/**') {
      before = {
        response.setHeader 'Version', grailsApplication.metadata['app.version']
        true
      }
    }
  }
}