krakend / krakend-documentation

All the documentation under http://www.krakend.io/docs/
Apache License 2.0
24 stars 107 forks source link

Docs example at service level is not working, request in not available ar endpoint/service level #183

Closed shadz3rg closed 1 year ago

shadz3rg commented 1 year ago

Docs article: https://www.krakend.io/docs/endpoints/lua/#lua-in-the-service-for-all-endpoints

Config snippet:

{
    "$schema": "https://www.krakend.io/schema/v3.json",
    "version": 3,
    "name": "REST API",
    "host": ["http://rest:3000"],
    "timeout": "5000ms",
    "extra_config": {
        "modifier/lua-endpoint": {
            "pre": "print('Lua service!'); local r = request.load(); r:headers('X-from-lua', '1234');"
        }
    },
    "endpoints": [
        {
            "backend": [{"url_pattern":"/users", "is_collection": true}],
            "endpoint": "/users",
            "method": "GET"
        }
    ]
}

Result:

krakend_1            | Lua service!
krakend_1            | [GIN] 2022/12/05 - 14:41:26 | 500 |      307.78µs |      172.19.0.1 | GET      "/users"
krakend_1            | Error #01: Line 1: attempt to index a non-table object(nil)
alombarte commented 1 year ago

Thanks @shadz3rg , you are right. Example fixed