public static Resource cookieResource(final String key, final Resource resource) {
return resource(id("cookie"), cookieConfigApplier(key, resource), new ResourceReader() {
@Override
public byte[] readFor(Optional<? extends Request> request) {
return new Cookies().encodeCookie(key, new String(resource.readFor(request))).getBytes();
}
});
}