Takes - code
This commit is contained in:
parent
e95f426032
commit
d37f95b991
|
@ -120,19 +120,6 @@
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<build>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/webapp</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<finalName>libraries-3</finalName>
|
<finalName>libraries-3</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -161,6 +148,16 @@
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/webapp</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
@ -172,6 +169,10 @@
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/webapp</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|
|
@ -3,10 +3,7 @@ package com.baeldung.takes;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import org.takes.Request;
|
|
||||||
import org.takes.Response;
|
import org.takes.Response;
|
||||||
import org.takes.facets.fallback.Fallback;
|
import org.takes.facets.fallback.Fallback;
|
||||||
import org.takes.facets.fallback.FbChain;
|
import org.takes.facets.fallback.FbChain;
|
||||||
|
@ -14,16 +11,11 @@ import org.takes.facets.fallback.FbStatus;
|
||||||
import org.takes.facets.fallback.RqFallback;
|
import org.takes.facets.fallback.RqFallback;
|
||||||
import org.takes.facets.fallback.TkFallback;
|
import org.takes.facets.fallback.TkFallback;
|
||||||
import org.takes.facets.fork.FkRegex;
|
import org.takes.facets.fork.FkRegex;
|
||||||
import org.takes.facets.fork.Fork;
|
|
||||||
import org.takes.facets.fork.TkFork;
|
import org.takes.facets.fork.TkFork;
|
||||||
import org.takes.http.Exit;
|
import org.takes.http.Exit;
|
||||||
import org.takes.http.FtBasic;
|
import org.takes.http.FtBasic;
|
||||||
import org.takes.misc.Opt;
|
import org.takes.misc.Opt;
|
||||||
import org.takes.rq.RqHref;
|
|
||||||
import org.takes.rs.RsText;
|
import org.takes.rs.RsText;
|
||||||
import org.takes.rs.RsWithBody;
|
|
||||||
import org.takes.rs.RsWithStatus;
|
|
||||||
import org.takes.rs.RsWithType;
|
|
||||||
import org.takes.tk.TkSlf4j;
|
import org.takes.tk.TkSlf4j;
|
||||||
|
|
||||||
import com.zaxxer.hikari.HikariConfig;
|
import com.zaxxer.hikari.HikariConfig;
|
||||||
|
@ -31,14 +23,6 @@ import com.zaxxer.hikari.HikariDataSource;
|
||||||
|
|
||||||
public final class TakesApp {
|
public final class TakesApp {
|
||||||
|
|
||||||
// public static void main(final String... args) throws Exception {
|
|
||||||
// new FtBasic(new TkFork(
|
|
||||||
// new FkRegex("/", "Hello, World!"),
|
|
||||||
// new FkRegex("/index", new TakesIndex()),
|
|
||||||
// new FkRegex("/contact", new TakesContact())
|
|
||||||
// ),6060).start(Exit.NEVER);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static void main(final String... args) throws IOException, SQLException {
|
public static void main(final String... args) throws IOException, SQLException {
|
||||||
new FtBasic(
|
new FtBasic(
|
||||||
new TkFallback(
|
new TkFallback(
|
||||||
|
@ -47,7 +31,7 @@ public final class TakesApp {
|
||||||
new FkRegex("/", "Hello, World!"),
|
new FkRegex("/", "Hello, World!"),
|
||||||
new FkRegex("/index", new TakesIndex()),
|
new FkRegex("/index", new TakesIndex()),
|
||||||
new FkRegex("/contact", new TakesContact()),
|
new FkRegex("/contact", new TakesContact()),
|
||||||
new FkRegex("\\A/createUser", new TakesCreateUser(TakesApp.dbConnection())),
|
new FkRegex("/createUser", new TakesCreateUser(TakesApp.dbConnection())),
|
||||||
new FkRegex("\\A/readUser", new TakesReadUser(TakesApp.dbConnection()))
|
new FkRegex("\\A/readUser", new TakesReadUser(TakesApp.dbConnection()))
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -67,26 +51,6 @@ public final class TakesApp {
|
||||||
).start(Exit.NEVER);
|
).start(Exit.NEVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// public static void main(final String... args) throws IOException {
|
|
||||||
//
|
|
||||||
// new FtBasic(
|
|
||||||
// new TkFork(
|
|
||||||
// new Fork() {
|
|
||||||
// @Override
|
|
||||||
// public Opt<Response> route(Request req) throws Exception {
|
|
||||||
// if (new RqHref.Base(req).href().path().equals("/entry")) {
|
|
||||||
// return new Opt.Single<Response>(new RsWithStatus(new RsWithType(new RsWithBody("hello this is for request"), "text/html"), 200));
|
|
||||||
// } else {
|
|
||||||
// return new Opt.Single<Response>(null);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// ),6060).start(Exit.NEVER);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
private static Connection dbConnection() throws SQLException {
|
private static Connection dbConnection() throws SQLException {
|
||||||
HikariConfig config = new HikariConfig();
|
HikariConfig config = new HikariConfig();
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.baeldung.takes;
|
package com.baeldung.takes;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -9,12 +8,9 @@ import java.sql.SQLException;
|
||||||
import org.takes.Request;
|
import org.takes.Request;
|
||||||
import org.takes.Response;
|
import org.takes.Response;
|
||||||
import org.takes.Take;
|
import org.takes.Take;
|
||||||
import org.takes.misc.Href;
|
|
||||||
import org.takes.rq.RqForm;
|
import org.takes.rq.RqForm;
|
||||||
import org.takes.rq.RqHref;
|
|
||||||
import org.takes.rq.form.RqFormSmart;
|
import org.takes.rq.form.RqFormSmart;
|
||||||
import org.takes.rs.RsHtml;
|
import org.takes.rs.RsWithStatus;
|
||||||
import org.takes.rs.RsVelocity;
|
|
||||||
|
|
||||||
public final class TakesCreateUser implements Take {
|
public final class TakesCreateUser implements Take {
|
||||||
|
|
||||||
|
@ -43,7 +39,7 @@ public final class TakesCreateUser implements Take {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RsHtml(new RsVelocity(this.getClass().getResource("/templates/index.vm") ,new RsVelocity.Pair("userName", "Anshul")));
|
return new RsWithStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import org.takes.Request;
|
||||||
import org.takes.Response;
|
import org.takes.Response;
|
||||||
import org.takes.Take;
|
import org.takes.Take;
|
||||||
import org.takes.misc.Href;
|
import org.takes.misc.Href;
|
||||||
import org.takes.misc.VerboseIterable;
|
|
||||||
import org.takes.rq.RqHref;
|
import org.takes.rq.RqHref;
|
||||||
import org.takes.rs.RsJson;
|
import org.takes.rs.RsJson;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue