forked from lda/telodendria
[ADD] Implement /tokens/[tokenname]
This commit is contained in:
parent
ed298aaa90
commit
688c1d3b9e
2 changed files with 11 additions and 3 deletions
|
@ -87,6 +87,7 @@ RouterBuild(void)
|
|||
R("/_telodendria/admin/v1/privileges", RoutePrivileges);
|
||||
R("/_telodendria/admin/v1/privileges/(.*)", RoutePrivileges);
|
||||
R("/_telodendria/admin/v1/deactivate/(.*)", RouteAdminDeactivate);
|
||||
R("/_telodendria/admin/v1/tokens/(.*)", RouteAdminTokens);
|
||||
R("/_telodendria/admin/v1/tokens", RouteAdminTokens);
|
||||
|
||||
#undef R
|
||||
|
|
|
@ -43,8 +43,6 @@ ROUTE_IMPL(RouteAdminTokens, path, argp)
|
|||
|
||||
HttpRequestMethod method = HttpRequestMethodGet(args->context);
|
||||
|
||||
(void) path;
|
||||
|
||||
if ((method != HTTP_GET))
|
||||
{
|
||||
char *msg = "Route only supports GET for now.";
|
||||
|
@ -75,7 +73,7 @@ ROUTE_IMPL(RouteAdminTokens, path, argp)
|
|||
goto finish;
|
||||
}
|
||||
|
||||
if (method == HTTP_GET)
|
||||
if (method == HTTP_GET && ArraySize(path) == 0)
|
||||
{
|
||||
Array *tokensarray = ArrayCreate();
|
||||
|
||||
|
@ -104,6 +102,15 @@ ROUTE_IMPL(RouteAdminTokens, path, argp)
|
|||
|
||||
DbListFree(tokens);
|
||||
}
|
||||
else if (method == HTTP_GET && ArraySize(path) == 1)
|
||||
{
|
||||
RegTokenInfo *info = RegTokenGetInfo(db, ArrayGet(path, 0));
|
||||
|
||||
response = RegTokenJSON(info);
|
||||
|
||||
RegTokenClose(info);
|
||||
RegTokenFree(info);
|
||||
}
|
||||
finish:
|
||||
UserUnlock(user);
|
||||
return response;
|
||||
|
|
Loading…
Reference in a new issue