////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////

Grails supports a tailored profile for creating REST applications that provides a more focused set of dependencies and commands.

To get started with the REST profile using the Grails Shell CLI, create an application specifying `rest-api` as the name of the profile:

[source,bash]
----
$ grails create-app my-api --profile rest-api
----

This will create a new REST application that provides the following features:

* Default set of commands for creating and generating REST endpoints
* Defaults to using JSON views for rendering responses (see the next section)
* Fewer plugins than the default Grails web profile (no GSP, no Asset Pipeline, nothing HTML related)

You will notice for example in the `grails-app/views` directory that there are `*.gson` files for rendering the default index page and as well as any 404 and 500 errors.

If you issue the following set of commands:

[source,bash]
----
$ grails create-domain-class my.api.Book
$ grails generate-all my.api.Book
----

Instead of CRUD HTML interface a REST endpoint is generated that produces JSON responses. In addition, the generated functional and unit tests by default test the REST endpoint.

To generate a REST application using the Forge CLI, use the following:

[source,console]
----
$ grails -t forge create-restapi my-api
----

This will create a new REST application with the same focused setup as above:

* Default set of commands for creating and generating REST endpoints
* Defaults to using JSON views for rendering responses (see the next section)
* Fewer plugins than a default Grails Web-style application (no GSP, no Asset Pipeline, nothing HTML related)

You will notice for example in the `grails-app/views` directory that there are `*.gson` files for rendering the default index page and as well as any 404 and 500 errors.

If you issue the following set of commands:

[source,console]
----
$ grails create-domain-class my.api.Book
$ ./gradlew runCommand -Pargs="generate-all my.api.Book"
----

NOTE: The generate-* commands are only available after adding the `org.apache.grails:grails-scaffolding` dependency to your project. They are not available by default in a REST application. Also, they will no longer produce *.gson files as that was a feature of the REST API-profile.

Instead of CRUD HTML interface a REST endpoint is generated that produces JSON responses. In addition, the generated functional and unit tests by default test the REST endpoint.
