public ApiThrottlingResult LoadIntoCache(IOwinRequest request) { try { var token = request.GetToken(); if (token != null) { GetQueryLimit(token.Value); return(ApiThrottlingResult.Success); } } catch (InvalidTokenFormatException) { return(ApiThrottlingResult.InvalidToken); } return(ApiThrottlingResult.Success); }
public ApiThrottlingResult Throttle(IOwinRequest request, int cost) { try { Guid?token = request.GetToken(); if (token != null) { return(Throttle(token.Value, cost)); } else { string ip = request.RemoteIpAddress; return(Throttle(ip, cost)); } } catch (InvalidTokenFormatException) { return(ApiThrottlingResult.InvalidToken); } }