Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
rainboyan committed Apr 29, 2024
1 parent 74ebb04 commit 964cf45
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,59 @@
Grace Plugin for using Grace/Grails app with [Inertia.js](https://inertiajs.com).


## Usage

Add dependency to the `build.gradle`,

```gradle
repositories {
mavenCentral()
}
dependencies {
implementation "org.graceframework.plugins:inertia:VERSION"
}
```

Inertia plugin supports controller-specific `withFormat()` method,

```groovy
class BookController {
def list() {
def books = Book.list()
withFormat {
inertia {
render(inertia: "Book/List", props: [bookList: books])
}
json {
render books as JSON
}
}
}
}
```

Also, this plugin supports extendsions for Grails Request and Response,

```groovy
// You can get Inertia request headers from Grails Request
request.inertia.version == request.getHeader('X-Inertia-Version')
// Check Inertia request?
if (request.inertia as boolean) { // or use request.isInertia()
template = 'book-detail'
}
// You can set Inertia response headers in Grails
response.inertia.location = 'http://localhost:8080/book/1'
```

## Development

### Build from source
Expand Down

0 comments on commit 964cf45

Please sign in to comment.