~lastrosade/getcraft

3d69c620b822501cc12dada0c50dbbfd2d918cc1 — jeremy.shields 5 years ago a9c57c7
atleasttheresareadme
1 files changed, 85 insertions(+), 0 deletions(-)

A README.md
A README.md => README.md +85 -0
@@ 0,0 1,85 @@
# getcraft

a simple json "API" engine

## Routes

Routes are in the routes.json file

### Arguments

- req = link (/link/to/thing)
- type = What you want to do with your link
- res = what is the target

### Types

    - text, sends res as text
    - file, sends file content
    - directory, sends files contents in directory as json
        ```json
            [
                {
                    "filename": "file1",
                    "content": "CoolFile"
                },
                {
                    "filename": "file2",
                    "content": "Nice content"
                }
            ]
        ```
    - route
        - get, returns the content of the routing array as json
        - refresh, refresh the routes array

#### optional

- status = force http status code

## Example

```json
{
    "routes": [

        // Respond with text
        {
            "req": "/text",
            "type": "text",
            "res": "text"
        },
        // Respond with the content of a file
        {
            "req": "/index",
            "type": "file",
            "res": "src/index.lua"
        },
        // Respond with a json containing file names and content
        {
            "req": "/src",
            "type": "directory",
            "res": "src/"
        },

        // Get the possible routes and their actions
        {
            "req": "/rg",
            "type": "route get"
        },
        // Refresh the routes file
        {
            "req": "/rr",
            "type": "route refresh"
        },

        // Optionally give http status code
        {
            "req": "/500",
            "type": "text",
            "status": 500,
            "res": "oh no"
        }
    ]
}
```
\ No newline at end of file