repositories {
mavenCentral()
}
dependencies {
implementation "org.graceframework.plugins:inertia:VERSION"
}
2 Usage
Version: 0.4.0-SNAPSHOT
2 Usage
Add dependency to the build.gradle
,
Inertia plugin supports controller-specific withFormat()
method,
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,
// 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'