Skip to content

Commit

Permalink
Add routes for /request/version and /request/remote in data server. A…
Browse files Browse the repository at this point in the history
…dd resource tree documentation for /request/version and /request/remote. Closes #85
  • Loading branch information
Héctor Hurtado committed Sep 9, 2020
1 parent fc19b92 commit 774b920
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
44 changes: 44 additions & 0 deletions docs/source/concepts/resource_tree.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,28 @@ then, when handling the request:
kapow.example
``/request/version`` Resource
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The HTTP version of the incoming request.

Sample Usage
^^^^^^^^^^^^

If the user runs:

.. code-block:: console
$ curl --http1.0 http://kapow.example:8080
then, when handling the request:

.. code-block:: console
$ kapow get /request/version
HTTP/1.0
``/request/path`` Resource
~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand All @@ -123,6 +145,28 @@ then, when handling the request:
/foo/bar
``/request/remote`` Resource
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The IP address of the host making the incoming request.

Sample Usage
^^^^^^^^^^^^

If the user runs:

.. code-block:: console
$ curl http://kapow.example:8080
then, when handling the request:

.. code-block:: console
$ kapow get /request/remote
192.168.100.156
``/request/matches/<name>`` Resource
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 2 additions & 0 deletions internal/server/data/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ func Run(bindAddr string, wg *sync.WaitGroup) {
// request
{"/handlers/{handlerID}/request/method", "GET", getRequestMethod},
{"/handlers/{handlerID}/request/host", "GET", getRequestHost},
{"/handlers/{handlerID}/request/version", "GET", getRequestVersion},
{"/handlers/{handlerID}/request/path", "GET", getRequestPath},
{"/handlers/{handlerID}/request/remote", "GET", getRequestRemote},
{"/handlers/{handlerID}/request/matches/{name}", "GET", getRequestMatches},
{"/handlers/{handlerID}/request/params/{name}", "GET", getRequestParams},
{"/handlers/{handlerID}/request/headers/{name}", "GET", getRequestHeaders},
Expand Down

0 comments on commit 774b920

Please sign in to comment.