web服务相关配置调整.

This commit is contained in:
aoshiguchen
2022-07-12 16:16:17 +08:00
parent 85c6b06674
commit 7f1488b570
4 changed files with 39 additions and 4 deletions
@@ -26,6 +26,8 @@ import fun.asgc.neutrino.core.annotation.Configuration;
import fun.asgc.neutrino.core.annotation.Value;
import lombok.Data;
import java.util.Set;
/**
*
* @author: aoshiguchen
@@ -48,9 +50,20 @@ public class ApplicationConfig {
@Data
public static class Http {
private Boolean enable;
@Value("${port:9999}")
@Value("${port:8080}")
private Integer port;
@Value("context-path")
private String contextPath;
@Value("${max-content-length-desc:64KB}")
private String maxContentLengthDesc;
@Value("max-content-length")
private Long maxContentLength;
@Value("static-resource")
private StaticResource staticResource;
}
@Data
public static class StaticResource{
private Set<String> locations;
}
}
@@ -25,6 +25,7 @@ import fun.asgc.neutrino.core.type.AbstractMatcherGroup;
import fun.asgc.neutrino.core.type.TypeMatchInfo;
import fun.asgc.neutrino.core.type.TypeMatcher;
import java.util.Collection;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -53,6 +54,17 @@ public class SetMatcherGroup extends AbstractMatcherGroup {
return matchInfo;
}
});
add(new TypeMatcher() {
@Override
public TypeMatchInfo match(Class<?> clazz, Class<?> targetClass) {
TypeMatchInfo matchInfo = new TypeMatchInfo(clazz, targetClass, this);
if (Set.class == targetClass && Collection.class.isAssignableFrom(clazz)) {
matchInfo.setTypeDistance(getDistanceMin() + 1);
matchInfo.setTypeConverter(((value, targetType) -> ((Collection)value).stream().collect(Collectors.toSet())));
}
return matchInfo;
}
});
}
}
@@ -25,6 +25,8 @@ import fun.asgc.neutrino.core.annotation.Autowired;
import fun.asgc.neutrino.core.annotation.Component;
import fun.asgc.neutrino.core.context.ApplicationConfig;
import fun.asgc.neutrino.core.context.ApplicationRunner;
import fun.asgc.neutrino.core.util.NumberUtil;
import fun.asgc.neutrino.core.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
/**
@@ -37,9 +39,12 @@ import lombok.extern.slf4j.Slf4j;
public class WebApplicationServer implements ApplicationRunner {
@Autowired
private ApplicationConfig rootApplicationConfig;
@Override
public void run(String[] args) {
log.debug("web服务启动...");
ApplicationConfig.Http http = rootApplicationConfig.getHttp();
if (StringUtil.notEmpty(http.getMaxContentLengthDesc()) && null == http.getMaxContentLength()) {
http.setMaxContentLength(NumberUtil.descriptionToSize(http.getMaxContentLengthDesc(), 64 * 1024));
}
}
}
@@ -3,8 +3,13 @@ neutrino:
name: neutrino-proxy-server
http:
enable: true
port:
port: 8080
context-path: /
max-content-length-desc: 128K
static-resource:
locations:
- "classpath:/static/"
- "classpath:/template/"
proxy:
protocol: