doc: style fixes

This commit is contained in:
pancho horrillo
2019-12-11 02:06:31 +01:00
parent 68efc98964
commit 37025211b1
+24 -26
View File
@@ -54,7 +54,6 @@ Add a New Route
Be aware that if you register more than one route with exactly the Be aware that if you register more than one route with exactly the
same path, only the first route added will be used. same path, only the first route added will be used.
**GET route** **GET route**
Defining a route: Defining a route:
@@ -73,7 +72,6 @@ Calling route:
$ curl http://localhost:8080/my/route $ curl http://localhost:8080/my/route
hello world hello world
**POST route** **POST route**
Defining route: Defining route:
@@ -177,11 +175,11 @@ If you need to write more complex actions, you can leverage multiline commands:
.. warning:: .. warning::
Be aware of the **"-"** at the end of the ``kapow route add`` command. Be aware of the **"-"** at the end of the ``kapow route add`` command.
It tells ``kapow route add`` to read commands from the :samp:`stdin`. It tells ``kapow route add`` to read commands from :samp:`stdin`.
.. warning:: .. warning::
If you want to learn more of multiline usage, see: `Here Doc If you want to learn more about multiline usage, see: `Here Doc
<https://en.wikipedia.org/wiki/Here_document>`_ <https://en.wikipedia.org/wiki/Here_document>`_
@@ -230,7 +228,7 @@ Testing with curl:
.. warning:: .. warning::
Please be aware that if you don't explicitly specified the value of Please be aware that if you don't explicitly specify the value of
the ``Content-Type`` header, *Kapow!* will guess it, effectively the ``Content-Type`` header, *Kapow!* will guess it, effectively
negating the effect of the ``X-Content-Type-Options`` header. negating the effect of the ``X-Content-Type-Options`` header.
@@ -245,16 +243,16 @@ Modify JSON by Using Shell Commands
.. note:: .. note::
Nowadays Web services are JSON-based so making your script JSON aware is Nowadays Web services are JSON-based, so making your script JSON aware is
probably a good choice. In order to be able to extract data from a JSON probably a good choice. In order to be able to extract data from a JSON
document as well as composing JSON documents from a script, you can leverage document as well as composing JSON documents from a script, you can leverage
`jq <https://https://stedolan.github.io/jq/>`_. `jq <https://https://stedolan.github.io/jq/>`_.
**Example 1** **Example #1**
In this example our *Kapow!* service will receive a JSON value with an incorrect In this example our *Kapow!* service will receive a JSON value with an incorrect
date, then our ``.pow`` file will fix it and return the correct value to the user. date, then our ``pow`` file will fix it and return the correct value to the user.
.. code-block:: console .. code-block:: console
:linenos: :linenos:
@@ -276,9 +274,9 @@ Call the service with ``curl``:
} }
**Example 2** **Example #2**
In this example we extract the name field from the incoming JSON document in In this example we extract the ``name`` field from the incoming JSON document in
order to generate a two-attribute JSON response. order to generate a two-attribute JSON response.
.. code-block:: console .. code-block:: console
@@ -309,8 +307,7 @@ Call the service with ``curl``:
Upload Files Upload Files
++++++++++++ ++++++++++++
**Example #1**
**Example 1**
Uploading a file using *Kapow!* is very simple: Uploading a file using *Kapow!* is very simple:
@@ -331,9 +328,9 @@ Uploading a file using *Kapow!* is very simple:
{"hello": "world"} {"hello": "world"}
**Example 2** **Example #2**
In this example we respond back with the line count of the file received in the request: In this example we reply the line count of the file received in the request:
.. code-block:: console .. code-block:: console
:linenos: :linenos:
@@ -358,12 +355,12 @@ In this example we respond back with the line count of the file received in the
$ cat file.txt $ cat file.txt
hello hello
World World
$ curl -F "myfile=@file.txt" http://localhost:8080/count-file-lines $ curl -F myfile=@file.txt http://localhost:8080/count-file-lines
file.txt has 2 lines file.txt has 2 lines
Protecting again Parameter Injection Attacks Protecting Against Parameter Injection Attacks
++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++
When you resolve variable values be careful to tokenize correctly by using When you resolve variable values be careful to tokenize correctly by using
double quotes. Otherwise you could be vulnerable to **parameter injection double quotes. Otherwise you could be vulnerable to **parameter injection
@@ -386,11 +383,11 @@ Exploiting using curl:
.. code-block:: console .. code-block:: console
:linenos: :linenos:
$ curl "http://localhost:8080/vulnerable/-lai%20hello" $ curl http://localhost:8080/vulnerable/-lai%20hello
**This example is NOT VULNERABLE to parameter injection** **This example is NOT VULNERABLE to parameter injection**
Be aware of how we add double quotes when we recover *value* data from the Note how we add double quotes when we recover *value* data from the
request: request:
.. code-block:: console .. code-block:: console
@@ -404,11 +401,10 @@ request:
.. warning:: .. warning::
Quotes around parameters only protect against injection of additional Quotes around parameters only protect against the injection of additional
arguments, but not against turning a non-option into option or arguments, but not against turning a non-option into option or vice-versa.
vice-versa. Note that for many commands we can leverage double-dash Note that for many commands we can leverage double-dash to signal the end of
to signal the end of the options. See the "Security Concern" section the options. See the "Security Concern" section on the docs.
on the docs.
Sending HTTP error codes Sending HTTP error codes
@@ -425,7 +421,7 @@ You can specify custom status code for HTTP response:
echo -n '401 error' | kapow set /response/body echo -n '401 error' | kapow set /response/body
EOF EOF
Testing with curl: Testing with ``curl``:
.. code-block:: console .. code-block:: console
:emphasize-lines: 10 :emphasize-lines: 10
@@ -447,6 +443,7 @@ Testing with curl:
< <
401 error 401 error
How to redirect using HTTP How to redirect using HTTP
++++++++++++++++++++++++++ ++++++++++++++++++++++++++
@@ -485,7 +482,7 @@ In this example we'll redirect our users to Google:
How to Execute Two Processes in Parallel How to Execute Two Processes in Parallel
++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++
We want to :samp:`ping` two machines parallel. *Kapow!* gets IPs from query We want to :samp:`ping` two machines parallel. *Kapow!* can get IPs from query
params: params:
.. code-block:: console .. code-block:: console
@@ -505,6 +502,7 @@ Calling with ``curl``:
$ curl -v http://localhost:8080/parallel/10.0.0.1/10.10.10.1 $ curl -v http://localhost:8080/parallel/10.0.0.1/10.10.10.1
Manage Cookies Manage Cookies
++++++++++++++ ++++++++++++++