2020-02-18 10:50:53 +02:00
|
|
|
package com.baeldung.takes;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
|
|
import org.takes.Request;
|
|
|
|
|
import org.takes.Response;
|
|
|
|
|
import org.takes.Take;
|
2020-02-22 19:58:19 +02:00
|
|
|
import org.takes.rq.form.RqFormSmart;
|
2020-02-21 11:00:23 +02:00
|
|
|
import org.takes.rs.RsHtml;
|
2020-02-18 10:50:53 +02:00
|
|
|
import org.takes.rs.RsVelocity;
|
|
|
|
|
|
|
|
|
|
public final class TakesIndex implements Take {
|
|
|
|
|
|
|
|
|
|
@Override
|
2020-02-22 16:19:02 +02:00
|
|
|
public Response act(final Request req) throws IOException {
|
2020-02-22 19:58:19 +02:00
|
|
|
RqFormSmart form = new RqFormSmart(req);
|
|
|
|
|
String username = form.single("username");
|
|
|
|
|
return new RsHtml(new RsVelocity(this.getClass().getResource("/templates/index.vm"), new RsVelocity.Pair("username", username)));
|
2020-02-18 10:50:53 +02:00
|
|
|
}
|
2020-02-21 11:00:23 +02:00
|
|
|
|
2020-02-18 10:50:53 +02:00
|
|
|
}
|