kore-doc

The kore documentation found under https://docs.kore.io/
Commits | Files | Refs | README | git clone https://git.kore.io/kore-doc.git

commit 5a17695f041b2a7c5f7d00222a86ddc67d788903
parent 1e59360db87d8238cd5f83da8f19a9bf939b2fb7
Author: Joris Vink <joris@coders.se>
Date:   Thu, 29 Nov 2018 15:32:31 +0100

add more docs

Diffstat:
SUMMARY.md | 4+++-
applications/filemap.md | 41+++++++++++++++++++++++++++++++++++++++++
applications/routes.md | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 110 insertions(+), 1 deletion(-)

diff --git a/SUMMARY.md b/SUMMARY.md @@ -7,7 +7,9 @@ * [Build framework](applications/building.md) * [Running](applications/running.md) * [build.conf](applications/buildconf_reference.md) - * [kore.conf](applications/koreconf.md) + * [Configuration](applications/koreconf.md) + * [Routes](applications/routes.md) + * [Filemap](applications/filemap.md) * [API](api/README.md) * [Buffers](api/buffers.md) * [HTTP](api/http.md) diff --git a/applications/filemap.md b/applications/filemap.md @@ -0,0 +1,41 @@ +# Filemaps + +A filemap is a configuration option in Kore that allows mapping +of on-disk files to a URI root. + +A filemap must be declared inside of a domain block. + +``` +domain kore.io { + filemap /3.2.0/ docs_3_2_0 +} +``` + +Where the first argument is the URI root and the second is the on-disk +path where the files will be served from. + +Thus from the example above the URL /3.2.0/index.html will be served from +the file docs\_3\_2\_0/index.html. + +Kore has the following builtin mime types: + +| Extension | MIME type| +| --- | --- | +| gif | image/gif | +| png | image/png | +| jpeg | image/jpeg | +| jpg | image/jpeg | +| zip | application/zip | +| pdf | application/pdf | +| json | application/json | +| js | application/javascript | +| htm | text/html | +| txt | text/plain | +| css | text/css | +| html | text/html | + +Additional mime types can be added via the configuration option **http\_media\_type** + +``` +http_media_type [mime type] ext1 ext2 extN +``` diff --git a/applications/routes.md b/applications/routes.md @@ -0,0 +1,66 @@ +# Configuring routes + +Configuring routes in Kore happens in the Kore configuration inside +of the domain configuration block. + +There are 2 type routes: + +* static routes +* dynamic routes + +Routes are evaluated from top to bottom. + +A static route is a path that is simply matched to the incoming path +for the request with a straight forward string comparison. + +A dynamic route is a regular expression that is matched against the +incoming path. This allows you to capture multiple routes towards +the same callback. + +``` +domain * { + static / root_page + static /about/ about_page + + dynamic ^.*$ redirect +} +``` + +In the example above the configuration specifies 2 static routes and one +dynamic route that captures all the other paths and sends them to some +redirection function. + +# Parameter configuration + +If you wish to receive parameters via a route you **must** define them +in the configuration **and** specify how they should be validated. + +Validation is not optional. + +After having defined the route you would continue with a param block: + + +``` +# First we must define a validator (in the global config) +validator v_number regex ^[0-9]$ + +# Then inside the domain {} configuration we can add the parameter block +# on an existing route: +params qs:get / { + validate id v_number +} +``` + +The params block syntax is as follows: + +``` +params method route { + validate parameter validator +} +``` + +Where **method** is the lowercase method (eg: post, get) and optionally +prefixed with **qs:** indicating the query string should be validated with +this parameters. + +If validation for a parameter fails it is filtered out.