use of com.dtflys.forest.reflection.MetaRequest in project forest by dromara.
the class LogEnabledLifeCycle method onMethodInitialized.
@Override
public void onMethodInitialized(ForestMethod method, LogEnabled annotation) {
MetaRequest metaRequest = method.getMetaRequest();
if (metaRequest == null) {
return;
}
ForestConfiguration configuration = method.getConfiguration();
LogConfiguration logConfiguration = metaRequest.getLogConfiguration();
if (logConfiguration == null) {
logConfiguration = new LogConfiguration();
metaRequest.setLogConfiguration(logConfiguration);
}
boolean logEnabled = annotation.value();
boolean logRequest = annotation.logRequest();
boolean logResponseStatus = annotation.logResponseStatus();
boolean logResponseContent = annotation.logResponseContent();
logConfiguration.setLogEnabled(logEnabled);
logConfiguration.setLogRequest(logRequest);
logConfiguration.setLogResponseStatus(logResponseStatus);
logConfiguration.setLogResponseContent(logResponseContent);
metaRequest.setLogConfiguration(logConfiguration);
}
use of com.dtflys.forest.reflection.MetaRequest in project forest by dromara.
the class BodyTypeLifeCycle method onMethodInitialized.
@Override
public void onMethodInitialized(ForestMethod method, BodyType annotation) {
Map<String, Object> attrs = ReflectUtils.getAttributesFromAnnotation(annotation);
String type = (String) attrs.get("type");
Object encodeClass = attrs.get("encoder");
MetaRequest metaRequest = method.getMetaRequest();
if (metaRequest == null) {
return;
}
metaRequest.setBodyType(type);
if (encodeClass != null && encodeClass instanceof Class && !((Class<?>) encodeClass).isInterface() && ForestEncoder.class.isAssignableFrom((Class<?>) encodeClass)) {
metaRequest.setEncoder((Class<? extends ForestEncoder>) encodeClass);
}
}
use of com.dtflys.forest.reflection.MetaRequest in project forest by dromara.
the class DeleteRequestLifeCycle method onMethodInitialized.
@Override
public void onMethodInitialized(ForestMethod method, Annotation annotation) {
MetaRequest metaRequest = createMetaRequest(annotation);
metaRequest.setType(ForestRequestType.DELETE.getName());
method.setMetaRequest(metaRequest);
}
use of com.dtflys.forest.reflection.MetaRequest in project forest by dromara.
the class GetRequestLifeCycle method onMethodInitialized.
@Override
public void onMethodInitialized(ForestMethod method, Annotation annotation) {
MetaRequest metaRequest = createMetaRequest(annotation);
metaRequest.setType("GET");
method.setMetaRequest(metaRequest);
}
use of com.dtflys.forest.reflection.MetaRequest in project forest by dromara.
the class HeadersLifeCycle method onMethodInitialized.
@Override
public void onMethodInitialized(ForestMethod method, Headers annotation) {
MetaRequest metaRequest = method.getMetaRequest();
String[] headers = annotation.value();
String[] oldHeaders = metaRequest.getHeaders();
int len = headers.length + oldHeaders.length;
String[] newHeaders = new String[headers.length + oldHeaders.length];
for (int i = 0; i < oldHeaders.length; i++) {
newHeaders[i] = oldHeaders[i];
}
for (int i = 0; i < headers.length; i++) {
newHeaders[oldHeaders.length + i] = headers[i];
}
// String[] newHeaders = ArrayUtils.addAll(oldHeaders, headers);
metaRequest.setHeaders(newHeaders);
}
Aggregations