6

当我有这样的 API 定义时:

(POST* "/register" []
    :body-params [username :- String,
                  password :- String,
                  name :- String]
    (ok)))

使名称可选的适当方法是什么?是吗:

(POST* "/register" []
    :body-params [username :- String,
                  password :- String,
                  {name :- String nil}]
    (ok)))
4

1 回答 1

8

如您所知,它使用letk管道符号,据我记得语法是正确的,但默认值应该与预期的类型一致,所以我会说它应该是而""不是=>nil(string? nil)false

(POST* "/register" []
    :body-params [username :- String,
                  password :- String,
                  {name :- String ""}]
    (ok)))
于 2015-08-03T15:40:24.143 回答