Skip to content

Commit bd144e0

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

File tree

1 file changed

+3
-5
lines changed
  • doc/code_snippets/snippets/config/instances.enabled/application_role_http_api

1 file changed

+3
-5
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,17 @@ local listen_address_schema = schema.new('listen_address', schema.record({
2020
host = schema.scalar({
2121
type = 'string',
2222
validate = validate_host,
23+
default = '127.0.0.1',
2324
}),
2425
port = schema.scalar({
2526
type = 'integer',
2627
validate = validate_port,
28+
default = 8080,
2729
}),
2830
}))
2931

3032
local function validate(cfg)
31-
if cfg.host and cfg.port then
32-
listen_address_schema:validate(cfg)
33-
else
34-
error("You need to set both host and port values")
35-
end
33+
listen_address_schema:validate(cfg)
3634
end
3735

3836
local function apply(cfg)

0 commit comments

Comments
 (0)