简体   繁体   中英

D case insensitive associative array?

Is it possible? I'm building a REST Api with vibe.d and implementing token authentication. Because I'm not aware in which casing the user will send me Authorization header parameter, I need to query it in case insensitive manner. For example:

string[string] foo;
foo["XXX"] = "YYY";
logInfo(*("xxx" in foo)); // BOOM. Exception here

Is it possible..?

Thanks

在存储或查询它们之前,只需将关联数组的所有键都小写即可。

if the case is either all lower or all upper, then you might have something like

"xxx" in foo && logInfo(foo["xxx"]);
"XXX" in foo && logInfo(foo["XXX"]);

maybe there's more efficient way to do this. If you don't have control over how the keys are entered in the AA, then it seems you have to check all casing variants when querying a specific key.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM