Closed shadz3rg closed 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)
Thanks @shadz3rg , you are right. Example fixed
Docs article: https://www.krakend.io/docs/endpoints/lua/#lua-in-the-service-for-all-endpoints
Config snippet:
Result: