use of com.dtflys.forest.reflection.MetaRequest in project forest by dromara.
the class PostRequestLifeCycle method onMethodInitialized.
@Override
public void onMethodInitialized(ForestMethod method, Annotation annotation) {
MetaRequest metaRequest = createMetaRequest(annotation);
metaRequest.setType(ForestRequestType.POST.getName());
method.setMetaRequest(metaRequest);
}
use of com.dtflys.forest.reflection.MetaRequest in project forest by dromara.
the class PutRequestLifeCycle method onMethodInitialized.
@Override
public void onMethodInitialized(ForestMethod method, Annotation annotation) {
MetaRequest metaRequest = createMetaRequest(annotation);
metaRequest.setType(ForestRequestType.PUT.getName());
method.setMetaRequest(metaRequest);
}
use of com.dtflys.forest.reflection.MetaRequest in project forest by dromara.
the class ProtobufBodyLifeCycle method onParameterInitialized.
@Override
public void onParameterInitialized(ForestMethod method, MappingParameter parameter, ProtobufBody annotation) {
super.onParameterInitialized(method, parameter, annotation);
MetaRequest metaRequest = method.getMetaRequest();
String methodName = methodName(method);
if (metaRequest == null) {
throw new ForestRuntimeException("[Forest] method '" + methodName + "' has not bind a Forest request annotation. Hence the annotation @BinaryBody cannot be bind on a parameter in this method.");
}
boolean hasDataFileAnn = false;
for (Parameter param : method.getMethod().getParameters()) {
Annotation dataFileAnn = param.getAnnotation(DataFile.class);
if (dataFileAnn != null) {
hasDataFileAnn = true;
break;
}
}
String contentTypeStr = metaRequest.getContentType();
if (StringUtils.isBlank(contentTypeStr) && !hasDataFileAnn) {
metaRequest.setContentType(ContentType.APPLICATION_X_PROTOBUF);
}
if (metaRequest.getBodyType() == null) {
metaRequest.setBodyType(ForestDataType.PROTOBUF);
}
parameter.setTarget(MappingParameter.TARGET_BODY);
}
use of com.dtflys.forest.reflection.MetaRequest in project forest by dromara.
the class TestInterfaceProxyHandler method testEmptyBaseURL.
@Test
public void testEmptyBaseURL() {
ProxyFactory<EmptyBaseURLClient> getClientProxyFactory = new ProxyFactory<>(configuration, EmptyBaseURLClient.class);
InterfaceProxyHandler<EmptyBaseURLClient> interfaceProxyHandler = new InterfaceProxyHandler(configuration, getClientProxyFactory, EmptyBaseURLClient.class);
MetaRequest metaRequest = interfaceProxyHandler.getBaseMetaRequest();
assertNull(metaRequest.getUrl());
}
Aggregations