use of com.tvd12.ezyhttp.server.core.annotation.DoGet in project ezyfox-examples by tvd12.
the class UserViewController method getUser.
@DoGet("/{username}")
public View getUser(@PathVariable("username") String username) {
User user = userService.getUser(username);
String msg = user != null ? "User " + username + " with info: " + user : "User " + username + " not found";
return View.builder().addVariable("message", msg).template("user-info").build();
}
use of com.tvd12.ezyhttp.server.core.annotation.DoGet in project ezyhttp by youngmonkeys.
the class MetricsController method cpuUsageGet.
@EzyFeature(DEFAULT_FEATURE_NAME)
@DoGet("/management/cpu-usage")
public CpuPoint cpuUsageGet() {
SystemMonitor monitor = SystemMonitor.getInstance();
EzyGcMonitor gcMonitor = monitor.getGcMonitor();
EzyCpuMonitor cpuMonitor = monitor.getCpuMonitor();
return CpuPoint.builder().systemCpuLoad(cpuMonitor.getSystemCpuLoad()).processCpuLoad(cpuMonitor.getProcessCpuLoad()).processGcActivity(gcMonitor.getProcessGcActivity()).build();
}
use of com.tvd12.ezyhttp.server.core.annotation.DoGet in project ezyhttp by youngmonkeys.
the class RequestHandlerMethod method fetchResponseType.
protected String fetchResponseType() {
DoGet doGet = method.getAnnotation(DoGet.class);
if (doGet != null) {
return DoGetAnnotations.getResponseType(doGet);
}
DoPost doPost = method.getAnnotation(DoPost.class);
if (doPost != null) {
return DoPostAnnotations.getResponseType(doPost);
}
DoPut doPut = method.getAnnotation(DoPut.class);
if (doPut != null) {
return DoPutAnnotations.getResponseType(doPut);
}
DoDelete doDelete = method.getAnnotation(DoDelete.class);
return DoDeleteAnnotations.getResponseType(doDelete);
}
use of com.tvd12.ezyhttp.server.core.annotation.DoGet in project ezyhttp by youngmonkeys.
the class RequestHandlerMethod method fetchRequestURIFragment.
protected String fetchRequestURIFragment() {
DoGet doGet = method.getAnnotation(DoGet.class);
if (doGet != null) {
return DoGetAnnotations.getURI(doGet);
}
DoPost doPost = method.getAnnotation(DoPost.class);
if (doPost != null) {
return DoPostAnnotations.getURI(doPost);
}
DoPut doPut = method.getAnnotation(DoPut.class);
if (doPut != null) {
return DoPutAnnotations.getURI(doPut);
}
DoDelete doDelete = method.getAnnotation(DoDelete.class);
return DoDeleteAnnotations.getURI(doDelete);
}
use of com.tvd12.ezyhttp.server.core.annotation.DoGet in project ezyfox-server by youngmonkeys.
the class EzyWebSocketServerCreatorTest method healthCheckServletTest.
@Test
public void healthCheckServletTest() {
// given
HealthCheckServlet sut = new HealthCheckServlet();
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
// when
MethodInvoker.create().object(sut).method("doGet").param(HttpServletRequest.class, request).param(HttpServletResponse.class, response).call();
// then
verify(response, times(1)).setStatus(200);
}
Aggregations