com.vtence.molecule.middlewares.DateHeader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of molecule Show documentation
Show all versions of molecule Show documentation
A web micro-framework for Java
package com.vtence.molecule.middlewares;
import com.vtence.molecule.Request;
import com.vtence.molecule.Response;
import com.vtence.molecule.lib.Clock;
import com.vtence.molecule.lib.SystemClock;
import static com.vtence.molecule.http.HeaderNames.DATE;
public class DateHeader extends AbstractMiddleware {
private final Clock clock;
public DateHeader() {
this(new SystemClock());
}
public DateHeader(Clock clock) {
this.clock = clock;
}
public void handle(Request request, Response response) throws Exception {
response.header(DATE, clock.now());
forward(request, response);
}
}