refactoring
This commit is contained in:
parent
d08f2a4e0c
commit
ca03f9cf4d
|
@ -6,6 +6,7 @@ import org.takes.Take;
|
|||
import org.takes.facets.fork.FkRegex;
|
||||
import org.takes.facets.fork.TkFork;
|
||||
import org.takes.http.Exit;
|
||||
import org.takes.http.Front;
|
||||
import org.takes.http.FtBasic;
|
||||
import org.takes.misc.Href;
|
||||
import org.takes.rq.RqHref;
|
||||
|
@ -18,32 +19,30 @@ import javax.json.JsonObject;
|
|||
public class ServerSandbox {
|
||||
|
||||
public static void main(final String... args) throws Exception {
|
||||
new FtBasic(
|
||||
new TkFork(
|
||||
new FkRegex("/list", new Take() {
|
||||
@Override
|
||||
public Response act(Request request) throws Exception {
|
||||
Href href = new RqHref.Base(request).href();
|
||||
Take fork = new TkFork(
|
||||
new FkRegex("/list", new Take() {
|
||||
@Override
|
||||
public Response act(Request request) throws Exception {
|
||||
Href href = new RqHref.Base(request).href();
|
||||
// URI uri = href.uri();
|
||||
Iterable<String> values = href.param("user");
|
||||
String name = values.iterator().next();
|
||||
Iterable<String> values = href.param("user");
|
||||
String name = values.iterator().next();
|
||||
|
||||
|
||||
JsonArray result = Json.createArrayBuilder()
|
||||
.add(Json.createObjectBuilder().add("name", name))
|
||||
.add(Json.createObjectBuilder().add("name", name))
|
||||
.build();
|
||||
JsonArray result = Json.createArrayBuilder()
|
||||
.add(Json.createObjectBuilder().add("name", name))
|
||||
.add(Json.createObjectBuilder().add("name", name))
|
||||
.build();
|
||||
|
||||
return new RsJson(result);
|
||||
return new RsJson(result);
|
||||
|
||||
|
||||
}
|
||||
}),
|
||||
new FkRegex("/", "hello, world!")
|
||||
|
||||
|
||||
), 8080
|
||||
).start(Exit.NEVER);
|
||||
}
|
||||
}),
|
||||
new FkRegex("/", "hello, world!")
|
||||
);
|
||||
Front ftBasic = new FtBasic(fork, 8080);
|
||||
ftBasic.start(Exit.NEVER);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue