Walrus API

Walrus provide you a simple way to make your own API, every route begining with api/ will be redirected to a controller in engine/api/
Using the Walrus API is way faster than the normal routing, it's great for all your ajax call when you use it as an internal API for example

Here is the route pattern:
    /api/controller/action/

The Walrus API tools handle for you HTTP response, the only available output is JSON for now

API controller

You can create a new API controller with the Walrus CLI, or create it yourself with this basic syntax:

    <?php

    namespace engine\api;

    use Walrus\core\WalrusAPI;

    class PollingController extends WalrusAPI
    {
        public function run()
        {
            return $data;
        }
    }

The api has the same action and model method as a normal controller

To make an API action you just need to return an array of data, it will be automatically parsed into JSON.
For exemple the following controller :

    public function run()
    {
        return array('key' => 'value');
    }

Will automatically output (if the HTTP response as the 200 status code):

    {
        status: 200,
        data: {
            key: 'value'
        }
    }