RestURI更名RestPath
This commit is contained in:
@@ -28,7 +28,7 @@ public class RequestCoderTest {
|
||||
|
||||
@Test
|
||||
public void run1() throws Exception {
|
||||
HttpSimpleRequest req1 = HttpSimpleRequest.create("/aaa");
|
||||
HttpSimpleRequest req1 = HttpSimpleRequest.createPath("/aaa");
|
||||
System.out.println("simpleRequest1: " + req1);
|
||||
byte[] bytes = HttpSimpleRequestCoder.getInstance().encode(req1);
|
||||
HttpSimpleRequest req2 = HttpSimpleRequestCoder.getInstance().decode(bytes);
|
||||
@@ -41,7 +41,7 @@ public class RequestCoderTest {
|
||||
|
||||
@Test
|
||||
public void run2() throws Exception {
|
||||
HttpSimpleRequest req1 = HttpSimpleRequest.create("/aaa");
|
||||
HttpSimpleRequest req1 = HttpSimpleRequest.createPath("/aaa");
|
||||
req1.addHeader("X-aaa", "aaa");
|
||||
req1.param("bean", "{}");
|
||||
System.out.println("simpleRequest1: " + req1);
|
||||
@@ -56,7 +56,7 @@ public class RequestCoderTest {
|
||||
|
||||
@Test
|
||||
public void run3() throws Exception {
|
||||
HttpSimpleRequest req1 = HttpSimpleRequest.create("/aaa");
|
||||
HttpSimpleRequest req1 = HttpSimpleRequest.createPath("/aaa");
|
||||
req1.addHeader("X-aaa", "aaa");
|
||||
req1.addHeader("X-bbb", "bbb1");
|
||||
req1.addHeader("X-bbb", "bbb2");
|
||||
|
||||
@@ -17,7 +17,7 @@ public class UploadTestServlet extends HttpServlet {
|
||||
|
||||
@Override
|
||||
public void execute(HttpRequest request, HttpResponse response) throws IOException {
|
||||
if (request.getRequestURI().contains("/uploadtest/send")) {
|
||||
if (request.getPath().contains("/uploadtest/send")) {
|
||||
send(request, response);
|
||||
} else {
|
||||
form(request, response);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class HelloEntity {
|
||||
@RestAddress
|
||||
private String clientaddr;
|
||||
|
||||
@RestURI
|
||||
@RestPath
|
||||
private String uri;
|
||||
|
||||
public HelloEntity() {
|
||||
|
||||
@@ -74,7 +74,7 @@ public class _DynHelloRestServlet1 extends SimpleRestServlet {
|
||||
@HttpMapping(url = "/hello/delete/", auth = false)
|
||||
public void delete(HttpRequest req, HttpResponse resp) throws IOException {
|
||||
HelloService service = _redkale_servicemap == null ? _redkale_service : _redkale_servicemap.get(req.getHeader(Rest.REST_HEADER_RESNAME, ""));
|
||||
int id = Integer.parseInt(req.getRequstURILastPath());
|
||||
int id = Integer.parseInt(req.getPathLastParam());
|
||||
service.deleteHello(id);
|
||||
resp.finishJson(RetResult.success());
|
||||
}
|
||||
@@ -129,7 +129,7 @@ public class _DynHelloRestServlet1 extends SimpleRestServlet {
|
||||
@HttpMapping(url = "/hello/find/", auth = false)
|
||||
public void find(HttpRequest req, HttpResponse resp) throws IOException {
|
||||
HelloService service = _redkale_servicemap == null ? _redkale_service : _redkale_servicemap.get(req.getHeader(Rest.REST_HEADER_RESNAME, ""));
|
||||
int id = Integer.parseInt(req.getRequstURILastPath());
|
||||
int id = Integer.parseInt(req.getPathLastParam());
|
||||
HelloEntity bean = service.findHello(id);
|
||||
resp.finishJson(bean);
|
||||
}
|
||||
@@ -137,21 +137,21 @@ public class _DynHelloRestServlet1 extends SimpleRestServlet {
|
||||
@HttpMapping(url = "/hello/asyncfind/", auth = false)
|
||||
public void asyncfind(HttpRequest req, HttpResponse resp) throws IOException {
|
||||
HelloService service = _redkale_servicemap == null ? _redkale_service : _redkale_servicemap.get(req.getHeader(Rest.REST_HEADER_RESNAME, ""));
|
||||
int id = Integer.parseInt(req.getRequstURILastPath());
|
||||
int id = Integer.parseInt(req.getPathLastParam());
|
||||
resp.finishJson(service.asyncFindHello(id));
|
||||
}
|
||||
|
||||
@HttpMapping(url = "/hello/asyncfind2/", auth = false)
|
||||
public void asyncfind2(HttpRequest req, HttpResponse resp) throws IOException {
|
||||
HelloService service = _redkale_servicemap == null ? _redkale_service : _redkale_servicemap.get(req.getHeader(Rest.REST_HEADER_RESNAME, ""));
|
||||
int id = Integer.parseInt(req.getRequstURILastPath());
|
||||
int id = Integer.parseInt(req.getPathLastParam());
|
||||
service.asyncFindHello(resp.createAsyncHandler(), id);
|
||||
}
|
||||
|
||||
@HttpMapping(url = "/hello/asyncfind3/", auth = false)
|
||||
public void asyncfind3(HttpRequest req, HttpResponse resp) throws IOException {
|
||||
HelloService service = _redkale_servicemap == null ? _redkale_service : _redkale_servicemap.get(req.getHeader(Rest.REST_HEADER_RESNAME, ""));
|
||||
int id = Integer.parseInt(req.getRequstURILastPath());
|
||||
int id = Integer.parseInt(req.getPathLastParam());
|
||||
service.asyncFindHello(resp.createAsyncHandler(HelloAsyncHandler.class), id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class _DynHelloRestServlet2 extends SimpleRestServlet {
|
||||
@HttpParam(name = "#", type = int.class, comment = "Hello对象id")
|
||||
public void delete(HttpRequest req, HttpResponse resp) throws IOException {
|
||||
HelloService2 service = _redkale_servicemap == null ? _redkale_service : _redkale_servicemap.get(req.getHeader(Rest.REST_HEADER_RESNAME, ""));
|
||||
int id = Integer.parseInt(req.getRequstURILastPath());
|
||||
int id = Integer.parseInt(req.getPathLastParam());
|
||||
service.deleteHello(id);
|
||||
resp.finishJson(RetResult.success());
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public class _DynHelloRestServlet2 extends SimpleRestServlet {
|
||||
@HttpParam(name = "#", type = int.class, comment = "Hello对象id")
|
||||
public void find(HttpRequest req, HttpResponse resp) throws IOException {
|
||||
HelloService2 service = _redkale_servicemap == null ? _redkale_service : _redkale_servicemap.get(req.getHeader(Rest.REST_HEADER_RESNAME, ""));
|
||||
int id = Integer.parseInt(req.getRequstURILastPath());
|
||||
int id = Integer.parseInt(req.getPathLastParam());
|
||||
HelloEntity bean = service.findHello(id);
|
||||
resp.finishJson(bean);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class VideoWebSocketServlet extends WebSocketServlet {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<String> onOpen(final HttpRequest request) {
|
||||
String uri = request.getRequestURI();
|
||||
String uri = request.getPath();
|
||||
int pos = uri.indexOf("/listen/");
|
||||
uri = uri.substring(pos + "/listen/".length());
|
||||
this.repeat = sessions.get(uri) != null;
|
||||
|
||||
Reference in New Issue
Block a user