Controller
isGet()
Signature
Section titled “Signature”isGet() — returns boolean
Available in: controller
Category: Miscellaneous Functions
Description
Section titled “Description”Checks if the current HTTP request method is GET. Useful for controlling logic depending on whether a page is being displayed or data is being requested via GET.
Examples
Section titled “Examples”component extends="Controller" {
public void function show() {
if (isGet()) {
// Display a form or data
post = model("Post").findByKey(params.id);
renderWith(action="show", data=post);
} else {
// Handle non-GET request (e.g., POST, DELETE)
flashInsert(error="Invalid request method.");
redirectTo(action="index");
}
}
}