public final class ExpiryCheckHandler extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
EXPIRE_AFTER_HEADER |
static String |
QUEUE_EXPIRE_AFTER_HEADER |
static String |
SERVER_TIMESTAMP_HEADER |
| Modifier and Type | Method and Description |
|---|---|
static org.joda.time.LocalDateTime |
getActualTime()
Returns the actual datetime.
|
static org.joda.time.LocalDateTime |
getExpirationTime(int expireAfter)
Returns the expiration time, based on the actual time
in addition with the expireAfter value.
|
static org.joda.time.LocalDateTime |
getExpirationTime(String serverTimestamp,
int expireAfter)
Returns the expiration time based on the given timestamp
in addition with the expireAfter value.
|
static Optional<String> |
getExpirationTimeAsString(int expireAfter) |
static Integer |
getExpireAfter(io.vertx.core.MultiMap headers)
Extracts the value of the "X-Expire-After" header.
|
static Optional<Integer> |
getExpireAfterConcerningCaseOfCorruptHeaderAndInfinite(io.vertx.core.MultiMap headers)
Delegates to
getExpireValue(String)
This is extended version of getExpireAfter(MultiMap) but also
returning -1 for infinite. |
static Integer |
getQueueExpireAfter(io.vertx.core.MultiMap headers)
Extracts the value of the "x-queue-expire-after" header.
|
static boolean |
isExpired(HttpRequest request)
Checks if the given request has expired or not.
|
static boolean |
isExpired(io.vertx.core.http.HttpServerRequest request)
Checks if the given request has expired or not.
|
static boolean |
isExpired(io.vertx.core.MultiMap headers)
Checks the expiration based on the given headers.
|
static boolean |
isExpired(io.vertx.core.MultiMap headers,
Long timestamp)
Checks the expiration based on the given headers and a timstamp in milliseconds.
|
static org.joda.time.LocalDateTime |
parseDateTime(String datetime)
Parses the given string to a LocalDateTime object.
|
static String |
printDateTime(org.joda.time.LocalDateTime datetime)
Prints the given datetime as a string.
|
static void |
setExpireAfter(HttpRequest request,
int expireAfter)
Sets an "X-Expire-After" header.
|
static void |
setExpireAfter(io.vertx.core.http.HttpServerRequest request,
int expireAfter)
Sets an "X-Expire-After" header.
|
static void |
setExpireAfter(io.vertx.core.MultiMap headers,
int expireAfter)
Sets an "X-Expire-After" header.
|
static void |
setQueueExpireAfter(HttpRequest request,
int queueExpireAfter)
Sets an "x-queue-expire-after" header.
|
static void |
setQueueExpireAfter(io.vertx.core.http.HttpServerRequest request,
int queueExpireAfter)
Sets an "x-queue-expire-after" header.
|
static void |
setQueueExpireAfter(io.vertx.core.MultiMap headers,
int queueExpireAfter)
Sets an "x-queue-expire-after" header.
|
static void |
updateServerTimestampHeader(HttpRequest request)
Checks if a "X-Server-Timestamp" header is set or not.
|
static void |
updateServerTimestampHeader(io.vertx.core.http.HttpServerRequest request)
Checks if a "X-Server-Timestamp" header is set or not.
|
static void |
updateServerTimestampHeader(io.vertx.core.MultiMap headers)
Checks if a "X-Server-Timestamp" header is set or not.
|
public static final String SERVER_TIMESTAMP_HEADER
public static final String EXPIRE_AFTER_HEADER
public static final String QUEUE_EXPIRE_AFTER_HEADER
public static void updateServerTimestampHeader(HttpRequest request)
request - requestpublic static void updateServerTimestampHeader(io.vertx.core.http.HttpServerRequest request)
request - requestpublic static void updateServerTimestampHeader(io.vertx.core.MultiMap headers)
headers - headerspublic static Integer getExpireAfter(io.vertx.core.MultiMap headers)
headers - headerspublic static Optional<Integer> getExpireAfterConcerningCaseOfCorruptHeaderAndInfinite(io.vertx.core.MultiMap headers)
getExpireValue(String)
This is extended version of getExpireAfter(MultiMap) but also
returning -1 for infinite.headers - Headers to fetch value from.The parsed expire-after value.
Returns empty in case getExpireValue(String) returned null.
public static Integer getQueueExpireAfter(io.vertx.core.MultiMap headers)
headers - headerspublic static boolean isExpired(HttpRequest request)
false is returned.request - requestpublic static boolean isExpired(io.vertx.core.http.HttpServerRequest request)
false is returned.request - requestpublic static boolean isExpired(io.vertx.core.MultiMap headers)
false
is returned.headers - headerspublic static boolean isExpired(io.vertx.core.MultiMap headers,
Long timestamp)
headers - headerspublic static org.joda.time.LocalDateTime getActualTime()
public static org.joda.time.LocalDateTime getExpirationTime(int expireAfter)
expireAfter - - in secondspublic static org.joda.time.LocalDateTime getExpirationTime(String serverTimestamp, int expireAfter)
serverTimestamp - serverTimestampexpireAfter - - in secondspublic static Optional<String> getExpirationTimeAsString(int expireAfter)
public static org.joda.time.LocalDateTime parseDateTime(String datetime)
datetime - datetimepublic static String printDateTime(org.joda.time.LocalDateTime datetime)
datetime - datetimepublic static void setQueueExpireAfter(HttpRequest request, int queueExpireAfter)
request - requestqueueExpireAfter - expireAfterpublic static void setExpireAfter(HttpRequest request, int expireAfter)
request - requestexpireAfter - expireAfterpublic static void setQueueExpireAfter(io.vertx.core.http.HttpServerRequest request,
int queueExpireAfter)
request - requestqueueExpireAfter - expireAfterpublic static void setExpireAfter(io.vertx.core.http.HttpServerRequest request,
int expireAfter)
request - requestexpireAfter - expireAfterpublic static void setQueueExpireAfter(io.vertx.core.MultiMap headers,
int queueExpireAfter)
headers - headersqueueExpireAfter - queueExpireAfterpublic static void setExpireAfter(io.vertx.core.MultiMap headers,
int expireAfter)
headers - headersexpireAfter - expireAfterCopyright © 2016–2018. All rights reserved.