Search in sources :

Example 6 with DoGet

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();
}
Also used : User(org.youngmonkeys.example.ezyhttp.website.user_management.entity.User) DoGet(com.tvd12.ezyhttp.server.core.annotation.DoGet)

Example 7 with DoGet

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();
}
Also used : SystemMonitor(com.tvd12.ezyhttp.server.management.monitor.SystemMonitor) EzyGcMonitor(com.tvd12.ezyfox.monitor.EzyGcMonitor) EzyCpuMonitor(com.tvd12.ezyfox.monitor.EzyCpuMonitor) EzyFeature(com.tvd12.ezyfox.annotation.EzyFeature) DoGet(com.tvd12.ezyhttp.server.core.annotation.DoGet)

Example 8 with DoGet

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);
}
Also used : DoPost(com.tvd12.ezyhttp.server.core.annotation.DoPost) DoPut(com.tvd12.ezyhttp.server.core.annotation.DoPut) DoDelete(com.tvd12.ezyhttp.server.core.annotation.DoDelete) DoGet(com.tvd12.ezyhttp.server.core.annotation.DoGet)

Example 9 with DoGet

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);
}
Also used : DoPost(com.tvd12.ezyhttp.server.core.annotation.DoPost) DoPut(com.tvd12.ezyhttp.server.core.annotation.DoPut) DoDelete(com.tvd12.ezyhttp.server.core.annotation.DoDelete) DoGet(com.tvd12.ezyhttp.server.core.annotation.DoGet)

Example 10 with DoGet

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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HealthCheckServlet(com.tvd12.ezyfoxserver.nio.builder.impl.EzyWebSocketServerCreator.HealthCheckServlet) HttpServletResponse(javax.servlet.http.HttpServletResponse) Test(org.testng.annotations.Test)

Aggregations

DoGet (com.tvd12.ezyhttp.server.core.annotation.DoGet)6 DoPost (com.tvd12.ezyhttp.server.core.annotation.DoPost)3 DoPut (com.tvd12.ezyhttp.server.core.annotation.DoPut)3 EzyFeature (com.tvd12.ezyfox.annotation.EzyFeature)2 HttpNotFoundException (com.tvd12.ezyhttp.core.exception.HttpNotFoundException)2 DoDelete (com.tvd12.ezyhttp.server.core.annotation.DoDelete)2 Test (org.testng.annotations.Test)2 Author (com.tvd12.ezydata.example.mongo.entity.Author)1 Book (com.tvd12.ezydata.example.mongo.entity.Book)1 Category (com.tvd12.ezydata.example.mongo.entity.Category)1 Author (com.tvd12.ezydata.example.redis.entity.Author)1 Book (com.tvd12.ezydata.example.redis.entity.Book)1 Category (com.tvd12.ezydata.example.redis.entity.Category)1 EzyCpuMonitor (com.tvd12.ezyfox.monitor.EzyCpuMonitor)1 EzyGcMonitor (com.tvd12.ezyfox.monitor.EzyGcMonitor)1 EzyThreadsMonitor (com.tvd12.ezyfox.monitor.EzyThreadsMonitor)1 EzyMethod (com.tvd12.ezyfox.reflect.EzyMethod)1 HealthCheckServlet (com.tvd12.ezyfoxserver.nio.builder.impl.EzyWebSocketServerCreator.HealthCheckServlet)1 RequestHandlerImplementer (com.tvd12.ezyhttp.server.core.asm.RequestHandlerImplementer)1 ControllerProxy (com.tvd12.ezyhttp.server.core.reflect.ControllerProxy)1