shors 0.13.0

Transport layer for cartridge + tarantool-module projects.
Documentation
 local function make_json_handler(fn)
    return function(req)
        local data = req:read()

        local status, body, headers = fn(req.method, req.path, req.query, req.headers, req.tstash, req.proto, req.peer, data)

        return {
            status = status,
            body = body,
            headers = headers,
        }
    end
end

local function remove_route(httpd, route_name)
    -- tnt-http 1.6.0 introduced httpd:delete(name) (uses iroutes[name] as index)
    if type(httpd.delete) == 'function'
            and httpd.iroutes and httpd.iroutes[route_name] ~= nil then
        httpd:delete(route_name)
        return
    end

    -- fallback for older httpd implementations:
    -- search and remove the route manually by name
    for i = #httpd.routes, 1, -1 do
        if httpd.routes[i].name == route_name then
            table.remove(httpd.routes, i)
        end
    end

    if httpd.iroutes then
        httpd.iroutes[route_name] = nil
    end
end

local function get_httpd()
    return assert(rawget(_G, 'pico') and rawget(_G, 'pico').httpd or require('cartridge').service_get('httpd'), 'Failed to get httpd service')
end

function register_handler(route, method, handler)
    local httpd = get_httpd()
    local metrics = require('metrics')

    local route_name = method .. ':' .. route
    remove_route(httpd, route_name)

    httpd:route(
            { method = method, path = route, name = route_name },
            metrics.http_middleware.v1(
                make_json_handler(handler),
                metrics.http_middleware.get_default_collector()
            )
    )
end

function delete_handler(route_name)
    local httpd = get_httpd()
    remove_route(httpd, route_name)
end