Initial commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.baeldung.takes;
|
||||
|
||||
import org.takes.http.Exit;
|
||||
import org.takes.http.FtBasic;
|
||||
import org.takes.http.FtCli;
|
||||
import org.takes.tk.TkClasspath;
|
||||
import org.takes.tk.TkWrap;
|
||||
import org.takes.Take;
|
||||
import org.takes.facets.fork.FkRegex;
|
||||
import org.takes.facets.fork.TkFork;
|
||||
|
||||
public final class TakesApp {
|
||||
|
||||
|
||||
|
||||
// public static void main(final String... args) throws Exception {
|
||||
// new FtBasic(new TkFork(new FkRegex("/", "hello, world... this is coming from Takes!")), 6060).start(Exit.NEVER);
|
||||
// }
|
||||
|
||||
public static void main(final String... args) throws Exception {
|
||||
new FtBasic(new TakesIndex(), 6060).start(Exit.NEVER);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.baeldung.takes;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.takes.Request;
|
||||
import org.takes.Response;
|
||||
import org.takes.Take;
|
||||
import org.takes.rs.RsVelocity;
|
||||
import org.takes.rs.RsWithBody;
|
||||
import org.takes.rs.RsWithStatus;
|
||||
import org.takes.rs.RsWithType;
|
||||
|
||||
public final class TakesIndex implements Take {
|
||||
|
||||
// @Override
|
||||
// public Response act(Request req) throws IOException {
|
||||
// return new RsWithStatus(new RsWithType(new RsWithBody("<html>Hello, world!</html>"), "text/html"), 200);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Response act(Request req) {
|
||||
return new RsVelocity("Hello, ${name}", new RsVelocity.Pair("name", "Jeffrey"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.baeldung.takes;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.takes.Request;
|
||||
import org.takes.Response;
|
||||
import org.takes.Take;
|
||||
import org.takes.rs.RsText;
|
||||
|
||||
public final class TakesServletApp implements Take {
|
||||
|
||||
private final ServletContext ctx;
|
||||
|
||||
public TakesServletApp(final ServletContext context) {
|
||||
this.ctx = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response act(final Request req) {
|
||||
return new RsText("Hello servlet!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.baeldung.takes;
|
||||
|
||||
import org.takes.Request;
|
||||
import org.takes.Response;
|
||||
import org.takes.Take;
|
||||
import org.takes.rs.RsText;
|
||||
|
||||
public final class TkRoute implements Take {
|
||||
|
||||
@Override
|
||||
public Response act(final Request request) {
|
||||
return new RsText("Hello, world!");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user