public String[] getPaths() { if (null != mapping) { return mapping.value(); } if (null != getRoute) { return getRoute.value(); } if (null != postRoute) { return postRoute.value(); } if (null != putRoute) { return putRoute.value(); } if (null != deleteRoute) { return deleteRoute.value(); } return DEFAULT_PATHS; } }
public HttpMethod getMethod() { if (null != mapping) { return mapping.method(); } if (null != getRoute) { return HttpMethod.GET; } if (null != postRoute) { return HttpMethod.POST; } if (null != putRoute) { return HttpMethod.PUT; } if (null != deleteRoute) { return HttpMethod.DELETE; } return HttpMethod.ALL; }
@Path class DemoController { @GetRoute public void hello(Response response) { response.text("Ok."); } }
@PostRoute("upload") @JSON public RestResponse upload(@MultipartParam FileItem fileItem) throws IOException { System.out.println(fileItem); fileItem.moveTo(new File(fileItem.getFileName())); return RestResponse.ok(); }
@GetRoute("exp") public String validatorException() { return "exp.html"; }
public void users(@Param String name) { }
public void findUser(@PathParam Long uid) { }
public void notify(@BodyParam NotifyType notifyType) { }
@Route("hi/:a/:b/:c") public void pathParam(Request request) { System.out.println(request.pathString("a")); System.out.println(request.pathString("b")); System.out.println(request.pathString("c")); }
/** * @author darren * @description * @date 2018/12/18 11:01 */ @WebSocket("/ws_anno") public class CustomWebSocketHandlerAnno extends BaseWebSocketHandler { @OnMessage public void OnMessage(WebSocketContext ctx) { System.out.println("ws from annotation @OnMessage:" + ctx.getSession().getUuid() + " said:" + ctx.getReqText()); } }
public String[] getPaths() { if (null != mapping) { return mapping.value(); } if (null != getRoute) { return getRoute.value(); } if (null != postRoute) { return postRoute.value(); } if (null != putRoute) { return putRoute.value(); } if (null != deleteRoute) { return deleteRoute.value(); } return DEFAULT_PATHS; } }
@GetRoute public void hello(Response response) { response.text("Ok."); } }
/** * @author biezhi * @date 2017/9/19 */ @Path public class IndexController { public void findUser(@PathParam Long uid) { } public void users(@Param String name) { } public void notify(@BodyParam NotifyType notifyType) { } }
public HttpMethod getMethod() { if (null != mapping) { return mapping.method(); } if (null != getRoute) { return HttpMethod.GET; } if (null != postRoute) { return HttpMethod.POST; } if (null != putRoute) { return HttpMethod.PUT; } if (null != deleteRoute) { return HttpMethod.DELETE; } return HttpMethod.ALL; }
@GetRoute("csrf") public void getCsrfToken(Request request, Response response) { response.text("token: " + request.attribute("_csrf_token")); }