use of com.tvd12.ezyhttp.server.core.annotation.DoGet in project ezyhttp by youngmonkeys.
the class RequestHandlerMethod method fetchHttpMethod.
protected HttpMethod fetchHttpMethod() {
DoGet doGet = method.getAnnotation(DoGet.class);
if (doGet != null) {
return HttpMethod.GET;
}
DoPost doPost = method.getAnnotation(DoPost.class);
if (doPost != null) {
return HttpMethod.POST;
}
DoPut doPut = method.getAnnotation(DoPut.class);
if (doPut != null) {
return HttpMethod.PUT;
}
return HttpMethod.DELETE;
}
use of com.tvd12.ezyhttp.server.core.annotation.DoGet in project ezyhttp by youngmonkeys.
the class RequestHandlerImplementerTest method implementOneFailed.
@Test
public void implementOneFailed() throws Exception {
// given
ControllerProxy controller = new ControllerProxy(new Controller());
RequestHandlerMethod handlerMethod = new RequestHandlerMethod("/", new EzyMethod(Controller.class.getDeclaredMethod("doGet")));
RequestHandlerImplementer sut = new RequestHandlerImplementer(controller, handlerMethod);
// when
Throwable e = Asserts.assertThrows(sut::implement);
// then
Asserts.assertEquals(0, handlerMethod.getParameterTypes().length);
Asserts.assertThat(e).isEqualsType(IllegalStateException.class);
}
use of com.tvd12.ezyhttp.server.core.annotation.DoGet in project ezyhttp by youngmonkeys.
the class MetricsController method threadsGet.
@EzyFeature(DEFAULT_FEATURE_NAME)
@DoGet("/management/thread-count")
public ThreadCountPoint threadsGet() {
EzyThreadsMonitor threadsMonitor = SystemMonitor.getInstance().getThreadsMonitor();
int threadCount = threadsMonitor.getThreadCount();
int daemonThreadCount = threadsMonitor.getDaemonThreadCount();
return ThreadCountPoint.builder().threadCount(threadCount).daemonThreadCount(daemonThreadCount).build();
}
use of com.tvd12.ezyhttp.server.core.annotation.DoGet in project ezyfox-examples by tvd12.
the class BookController method getBook.
@DoGet("/books/{bookId}")
public BookResponse getBook(@PathVariable Long bookId) {
Book book = bookRepository.findById(bookId);
if (book == null) {
throw new HttpNotFoundException("not found book with id: " + bookId);
}
Author author = authorRepository.findById(book.getAuthorId());
Category category = categoryRepository.findById(book.getCategoryId());
return entityToResponseConverter.toBookResponse(book, author, category);
}
use of com.tvd12.ezyhttp.server.core.annotation.DoGet in project ezyfox-examples by tvd12.
the class BookController method getBook.
@DoGet("/books/{bookId}")
public BookResponse getBook(@PathVariable Long bookId) {
Book book = bookMap.get(bookId);
if (book == null) {
throw new HttpNotFoundException("not found book with id: " + bookId);
}
Author author = authorMap.get(book.getAuthorId());
Category category = categoryMap.get(book.getCategoryId());
return entityToResponseConverter.toBookResponse(book, author, category);
}
Aggregations