Grails 3 web vs web-api profiles

Grails 3.0.5 was released September the 4th.

I found this in the release notes:

This release features the first version of the web-api profile for creating REST applications. This profile will evolve further in Grails 3.1

I am currently using Grails 3 for a REST API; web-api profile seemed tailor specifically to me.  So I went for a comparison.

I created an app with the default profile web

$ grails create-app myapp

and another app with the new profile webapi

$ grails create-app myappweb --profile=web-api

build.gradle differences:

In the web-api profile the assets and grails-gsp plugins are gone. Moreover the dependency

compile "org.grails:grails-dependencies"

has been replaced by:

compile "org.grails:grails-plugin-url-mappings"
compile "org.grails:grails-plugin-rest"
compile "org.grails:grails-plugin-services"
compile "org.grails:grails-plugin-datasource"
compile "org.grails:grails-plugin-async"

grails-app folder differences

On the left web profile, on the right web-api profile

Comparison of grails-app folder between web and web-api profile

grails-app/assets, grails-app/taglib and grails-app/views folders are gone from the web-api profile.

application.yml changes

Obviously the profile name changes:

    profile: web-api

The web-api profile removes the pdf mime-type too.

And the block:

            codec: html
            encoding: UTF-8
            htmlcodec: xml
                expression: html
                scriptlets: html
                taglib: none
                staticparts: none
        queries: false
        use_second_level_cache: true
        use_query_cache: false
        region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory'

        unique-names: true

is in the web-api profile:

            queries: false

views and views/gsp part is gone from the web-api profile.

URLMappings.groovy changes

Since GSP views are gone from web-api profile the default /, 500 and 404 views are replaced from:

class UrlMappings {

    static mappings = {


class UrlMappings {

    static mappings = {
        "/"(controller: 'index')
        "500"(controller: 'InternalServerError')
        "404"(controller: 'NotFound')

The Index.groovy, InternalServerError.groovy and NotFound.groovy have been included in the web-api profile. These controllers send JSON response with the appropriate http status code.

Do you like to read about Groovy/Grails development? Yes, then Subscribe to Groovy Calamari a weekly curated email newsletter about the Groovy ecosystem which I happen to write 😉

1 thought on “Grails 3 web vs web-api profiles

  1. Owen Rubel

    The web-api and Grails web both use the old API pattern wherein the communication layer is bound to business logic(controller) making it impossible to share data and functionality with services in a distributed architecture (ie proxy, MQ, etc). This creates an architectural cross cutting concern causing duplication, entanglement, dropped threads, IO bound processes, etc.

    The new api pattern separates the communication layer from business logic allowing functionality to be shared and synchronized in distributed architectures and data not only to be shared/synchronized but also reloaded on the fly without restarting any services (

    Through this separation, this not only does increase speed and scalability (, but it enables nearly everything to be automated and stateless.


Leave a Reply

Your email address will not be published. Required fields are marked *