Skip to content
This repository has been archived by the owner on May 15, 2020. It is now read-only.

Commit

Permalink
Add http://pow/env.json endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
sstephenson committed Nov 14, 2011
1 parent d1e8abc commit 0d0c62f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
3 changes: 3 additions & 0 deletions lib/http_server.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 15 additions & 6 deletions src/http_server.coffee
Expand Up @@ -99,19 +99,28 @@ module.exports = class HttpServer extends connect.HTTPServer
req.pow = {host}
next()

# Serve requests for status information at `http://pow/config.json`
# and `http://pow/status.json`. The former returns a JSON
# representation of the server `Configuration` instance; the latter
# includes information about the current server version, number of
# requests handled, and process ID. Third-party utilities may use
# these endpoints to inspect a running Pow server.
# Serve requests for status information at `http://pow/`. The status
# endpoints are:
#
# * `/config.json`: Returns a JSON representation of the server's
# `Configuration` instance.
# * `/env.json`: Returns the environment variables that all spawned
# applications inherit.
# * `/status.json`: Returns information about the current server
# version, number of requests handled, and process ID.
#
# Third-party utilities may use these endpoints to inspect a running
# Pow server.
handlePowRequest: (req, res, next) =>
return next() unless req.pow.host is "pow"

switch req.url
when "/config.json"
res.writeHead 200
res.end JSON.stringify @configuration
when "/env.json"
res.writeHead 200
res.end JSON.stringify @configuration.env
when "/status.json"
res.writeHead 200
res.end JSON.stringify this
Expand Down

0 comments on commit 0d0c62f

Please sign in to comment.