Skip to content

Commit cce41ab

Browse files
committed
Schema validation: update HTTP sample 3
1 parent bd144e0 commit cce41ab

File tree

1 file changed

+4
-1
lines changed
  • doc/code_snippets/snippets/config/instances.enabled/application_role_http_api

1 file changed

+4
-1
lines changed

doc/code_snippets/snippets/config/instances.enabled/application_role_http_api/http-api.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ local function apply(cfg)
3737
if httpd then
3838
httpd:stop()
3939
end
40-
httpd = require('http.server').new(cfg.host, cfg.port)
40+
local cfg_with_defaults = listen_address_schema:apply_default(cfg)
41+
local host = listen_address_schema:get(cfg_with_defaults, 'host')
42+
local port = listen_address_schema:get(cfg_with_defaults, 'port')
43+
httpd = require('http.server').new(host, port)
4144
local response_headers = { ['content-type'] = 'application/json' }
4245
httpd:route({ path = '/band/:id', method = 'GET' }, function(req)
4346
local id = req:stash('id')

0 commit comments

Comments
 (0)