RestURI更名RestPath

This commit is contained in:
redkale
2023-11-21 18:02:34 +08:00
parent aefd10c029
commit 7433530998
25 changed files with 258 additions and 311 deletions

View File

@@ -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");

View File

@@ -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);

View File

@@ -38,7 +38,7 @@ public class HelloEntity {
@RestAddress
private String clientaddr;
@RestURI
@RestPath
private String uri;
public HelloEntity() {

View File

@@ -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);
}
}

View File

@@ -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);
}

View File

@@ -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;