-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is allows a client to do health checks from JavaScript Review: https://rb.mesosphe.re/r/573
- Loading branch information
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package mesosphere.chaos.http | ||
|
||
import javax.servlet.http.{HttpServletRequest, HttpServletResponse, HttpServlet} | ||
|
||
/** | ||
* An HTTP servlets which outputs a {@code text/plain} {@code "pong"} response. | ||
* | ||
* PingServlet from com.codahale.metrics, with CORBS header added. | ||
*/ | ||
|
||
class PingServlet extends HttpServlet { | ||
|
||
private final val CONTENT_TYPE = "text/plain" | ||
private final val CONTENT = "pong" | ||
private final val CACHE_CONTROL = "Cache-Control" | ||
private final val NO_CACHE = "must-revalidate,no-cache,no-store" | ||
private final val ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin" | ||
private final val STAR = "*" | ||
|
||
protected override def doGet(req: HttpServletRequest, resp: HttpServletResponse) { | ||
resp.setStatus(HttpServletResponse.SC_OK) | ||
resp.setHeader(CACHE_CONTROL, NO_CACHE) | ||
resp.setHeader(ACCESS_CONTROL_ALLOW_ORIGIN, STAR) | ||
resp.setContentType(CONTENT_TYPE) | ||
|
||
val writer = resp.getWriter | ||
try { | ||
writer.println(CONTENT) | ||
} | ||
finally { | ||
writer.close() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters