From cece8ace6e906c615303042221493f1f887af2e3 Mon Sep 17 00:00:00 2001 From: andreyaksenov Date: Tue, 27 Aug 2024 12:01:00 +0300 Subject: [PATCH] Schema validation: update HTTP sample 3 --- .../instances.enabled/application_role_http_api/http-api.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/code_snippets/snippets/config/instances.enabled/application_role_http_api/http-api.lua b/doc/code_snippets/snippets/config/instances.enabled/application_role_http_api/http-api.lua index 4d2cda6c3..b5bb98096 100644 --- a/doc/code_snippets/snippets/config/instances.enabled/application_role_http_api/http-api.lua +++ b/doc/code_snippets/snippets/config/instances.enabled/application_role_http_api/http-api.lua @@ -37,7 +37,10 @@ local function apply(cfg) if httpd then httpd:stop() end - httpd = require('http.server').new(cfg.host, cfg.port) + local cfg_with_defaults = listen_address_schema:apply_default(cfg) + local host = listen_address_schema:get(cfg_with_defaults, 'host') + local port = listen_address_schema:get(cfg_with_defaults, 'port') + httpd = require('http.server').new(host, port) local response_headers = { ['content-type'] = 'application/json' } httpd:route({ path = '/band/:id', method = 'GET' }, function(req) local id = req:stash('id')