当我有这样的 API 定义时:
When I have a definition of an API like this:
(POST* "/register" []
:body-params [username :- String,
password :- String,
name :- String]
(ok)))
使名称可选的适当方法是什么?是吗:
what's the appropriate way of making name optional? Is it:
(POST* "/register" []
:body-params [username :- String,
password :- String,
{name :- String nil}]
(ok)))
你知道它使用 letk
管道符号,据我记得语法是正确的,但默认值应该与预期的类型,所以我会说它应该是 ""
而不是 nil
作为 (string? nil)
=> false
As you know it uses letk
plumbing notation and as far as I recall the syntax is correct but the default value should be consistent with the expected type so I'd say it should be ""
rather than nil
as (string? nil)
=> false
(POST* "/register" []
:body-params [username :- String,
password :- String,
{name :- String ""}]
(ok)))