use of com.tvd12.ezyhttp.server.core.reflect.RequestHandlerMethod in project ezyhttp by youngmonkeys.
the class RequestHandlerMethodTest method isPaymentAndFeatureTest.
@Test
public void isPaymentAndFeatureTest() throws Exception {
// given
RequestHandlerMethod sut = new RequestHandlerMethod("/get", new EzyMethod(InternalController.class.getDeclaredMethod("buySomething")));
// when
// then
Asserts.assertTrue(sut.isPayment());
Asserts.assertEquals(sut.getFeature(), "hello.world");
}
use of com.tvd12.ezyhttp.server.core.reflect.RequestHandlerMethod in project ezyhttp by youngmonkeys.
the class RequestHandlersImplementer method implement.
public Map<RequestURI, List<RequestHandler>> implement(Object controller) {
Map<RequestURI, List<RequestHandler>> handlers = new HashMap<>();
ControllerProxy proxy = new ControllerProxy(controller);
String feature = proxy.getFeature();
for (RequestHandlerMethod method : proxy.getRequestHandlerMethods()) {
RequestHandlerImplementer implementer = newImplementer(proxy, method);
RequestHandler handler = implementer.implement();
HttpMethod httpMethod = handler.getMethod();
String requestURI = handler.getRequestURI();
String methodFeature = method.getFeature();
RequestURIMeta uriMeta = RequestURIMeta.builder().api(method.isApi() || proxy.isApi()).authenticated(method.isAuthenticated() || proxy.isAuthenticated()).management(method.isManagement() || proxy.isManagement()).payment(method.isPayment() || proxy.isPayment()).feature(methodFeature != null ? methodFeature : feature).build();
RequestURI uri = new RequestURI(httpMethod, requestURI, uriMeta);
handlers.computeIfAbsent(uri, k -> new ArrayList<>()).add(handler);
}
return handlers;
}
use of com.tvd12.ezyhttp.server.core.reflect.RequestHandlerMethod in project ezyhttp by youngmonkeys.
the class ControllerProxy method fetchRequestHandlerMethods.
protected List<RequestHandlerMethod> fetchRequestHandlerMethods() {
List<RequestHandlerMethod> list = new ArrayList<>();
List<EzyMethod> methods = clazz.getPublicMethods(this::isRequestHandlerMethod);
for (EzyMethod method : methods) {
RequestHandlerMethod m = new RequestHandlerMethod(requestURI, method);
list.add(m);
}
return list;
}
Aggregations