Skip to content

Commit

Permalink
Expose /xh/ping as whitelisted route for uptime/reachability checks (
Browse files Browse the repository at this point in the history
…#393)

+ Response from `xh/ping` now about as minimal as possible - no longer aliased to `xh/version` so no longer reading a config for upgrade mode.
+ Remove pre-existing `ping` properties from `version` endpoint (timestamp, success:true) - nothing has ever expected those from `version`
+ Retain legacy `/ping` alias, but prefer this new path going forward.
  • Loading branch information
amcclain authored Sep 9, 2024
1 parent 9c6a442 commit 33ffd0f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 22.0-SNAPSHOT

### ⚙️ Technical

* Exposed `/xh/ping` as whitelisted route for basic uptime/reachability checks. Retained legacy
`/ping` alias, but prefer this new path going forward.

## 21.0.1 - 2024-09-05

### 🐞 Bug Fixes
Expand Down
4 changes: 3 additions & 1 deletion grails-app/controllers/io/xh/hoist/UrlMappings.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class UrlMappings {
"/$controller/$action?/$id?(.$format)?"{}

"404" (controller: 'xh', action: 'notFound')
"/ping" (controller: 'xh', action: 'version')

// Legacy alias for /xh/ping
"/ping" (controller: 'xh', action: 'ping')

//------------------------
// Rest Support
Expand Down
15 changes: 12 additions & 3 deletions grails-app/controllers/io/xh/hoist/impl/XhController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,26 @@ class XhController extends BaseController {
//-----------------------
// Misc
//-----------------------
/**
* Whitelisted (pre-auth) endpoint with minimal app identifier, for uptime/reachability checks.
* Also reachable via legacy `/ping` alias (via `UrlMappings`), but prefer `/xh/ping`.
*/
def ping() {
renderJSON(
appCode: Utils.appCode,
timestamp: System.currentTimeMillis(),
success: true
)
}

/**
* Whitelisted (pre-auth) endpoint with minimal app identifier and version info.
* Also reachable (for backwards compatibility) via /ping, as per `UrlMappings`.
*/
def version() {
renderJSON(
appCode: Utils.appCode,
appVersion: Utils.appVersion,
appBuild: Utils.appBuild,
timestamp: System.currentTimeMillis(),
success: true,
// TODO - this is a temporary measure to ensure that clients running hoist-react < 67
// prompt for upgrade when a new app release is deployed with hoist-core >= 21.
// Going forward clients will read these instructions from `xh/environmentPoll`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ abstract class BaseAuthenticationService extends BaseService {
* session within their completeAuthentication() implementations.
*/
protected List<String> whitelistURIs = [
'/ping',
'/ping', // legacy alias for /xh/ping (via UrlMappings)
'/xh/login',
'/xh/logout',
'/xh/ping',
'/xh/version',
'/xh/authConfig'
]
Expand Down

0 comments on commit 33ffd0f

Please sign in to comment.