diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/context/ApplicationContext.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/context/ApplicationContext.java index 86246b5b..68b36880 100644 --- a/neutrino-core/src/main/java/fun/asgc/neutrino/core/context/ApplicationContext.java +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/context/ApplicationContext.java @@ -74,9 +74,9 @@ public class ApplicationContext implements LifeCycle { GlobalConfig.setIsContainerStartup(true); this.rootBeanFactory = new SimpleBeanFactory("rootBeanFactory"); this.applicationBeanFactory = new SimpleBeanFactory(rootBeanFactory, "applicationBeanFactory"); - this.rootBeanFactory.registerBean(environment, "rootEnvironment"); - this.rootBeanFactory.registerBean(this, "rootApplicationContext"); - this.rootBeanFactory.registerBean(environment.getConfig(), "rootApplicationConfig"); + this.rootBeanFactory.registerBean(environment); + this.rootBeanFactory.registerBean(this); + this.rootBeanFactory.registerBean(environment.getConfig()); register(); List beanFactoryAwareList = this.applicationBeanFactory.getBeanList(BeanFactoryAware.class); if (CollectionUtil.notEmpty(beanFactoryAwareList)) { diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/context/ExtensionServiceLoader.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/context/ExtensionServiceLoader.java index d6a030c0..43deca4c 100644 --- a/neutrino-core/src/main/java/fun/asgc/neutrino/core/context/ExtensionServiceLoader.java +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/context/ExtensionServiceLoader.java @@ -25,6 +25,8 @@ import fun.asgc.neutrino.core.annotation.Autowired; import fun.asgc.neutrino.core.annotation.Component; import fun.asgc.neutrino.core.annotation.NonIntercept; import fun.asgc.neutrino.core.bean.SimpleBeanFactory; +import fun.asgc.neutrino.core.web.HttpRequestHandler; +import fun.asgc.neutrino.core.web.WebApplicationContext; import fun.asgc.neutrino.core.web.WebApplicationServer; /** @@ -36,7 +38,7 @@ import fun.asgc.neutrino.core.web.WebApplicationServer; @Component public class ExtensionServiceLoader implements ApplicationRunner { @Autowired - private ApplicationConfig rootApplicationConfig; + private ApplicationConfig applicationConfig; @Autowired private SimpleBeanFactory applicationBeanFactory; @@ -46,13 +48,13 @@ public class ExtensionServiceLoader implements ApplicationRunner { } private void startHttpServer() { - if (null == rootApplicationConfig) { + if (null == applicationConfig) { return; } - ApplicationConfig.Http http = rootApplicationConfig.getHttp(); + ApplicationConfig.Http http = applicationConfig.getHttp(); if (null == http || null == http.getEnable() || !http.getEnable()) { return; } - applicationBeanFactory.registerBean(WebApplicationServer.class); + applicationBeanFactory.registerBean(WebApplicationContext.class); } } diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/HttpMethod.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/HttpMethod.java new file mode 100644 index 00000000..8b97c6e3 --- /dev/null +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/HttpMethod.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web; + +import fun.asgc.neutrino.core.util.StringUtil; + +/** + * + * @author: aoshiguchen + * @date: 2022/7/15 + */ +public enum HttpMethod { + GET,POST; + + public static HttpMethod of(String method) { + if (StringUtil.isEmpty(method)) { + return null; + } + return HttpMethod.valueOf(method.toUpperCase()); + } +} diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/HttpRequestHandler.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/HttpRequestHandler.java new file mode 100644 index 00000000..3ddb09fe --- /dev/null +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/HttpRequestHandler.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web; + +import fun.asgc.neutrino.core.annotation.Autowired; +import fun.asgc.neutrino.core.annotation.Component; +import fun.asgc.neutrino.core.annotation.NonIntercept; +import fun.asgc.neutrino.core.context.ApplicationConfig; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.http.FullHttpRequest; + +/** + * + * @author: aoshiguchen + * @date: 2022/7/15 + */ +@NonIntercept +@Component +public class HttpRequestHandler { + @Autowired + private ApplicationConfig applicationConfig; + + public void handle(ChannelHandlerContext context, FullHttpRequest request) { + // TODO + System.out.println("hello"); + } + +} diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/WebApplicationContext.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/WebApplicationContext.java new file mode 100644 index 00000000..fb62f99e --- /dev/null +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/WebApplicationContext.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web; + +import fun.asgc.neutrino.core.annotation.*; +import fun.asgc.neutrino.core.bean.SimpleBeanFactory; +import fun.asgc.neutrino.core.context.ApplicationContext; +import fun.asgc.neutrino.core.context.ApplicationRunner; +import lombok.Data; +import lombok.experimental.Accessors; +import lombok.extern.slf4j.Slf4j; + +/** + * + * @author: aoshiguchen + * @date: 2022/7/15 + */ +@Accessors(chain = true) +@Data +@Slf4j +@NonIntercept +@Component +public class WebApplicationContext implements ApplicationRunner { + @Autowired + private ApplicationContext applicationContext; + @Autowired + private SimpleBeanFactory applicationBeanFactory; + /** + * bean工厂 + */ + private SimpleBeanFactory webApplicationBeanFactory; + + @Init + public void init() { + this.webApplicationBeanFactory = new SimpleBeanFactory(applicationBeanFactory, "webApplicationBeanFactory"); + this.webApplicationBeanFactory.init(); + // TODO 初始化路由信息 + } + + @Destroy + public void destroy() { + this.webApplicationBeanFactory.destroy(); + } + + @Override + public void run(String[] args) throws Exception { + this.webApplicationBeanFactory.registerBean(HttpRequestHandler.class); + this.webApplicationBeanFactory.registerBean(WebApplicationServer.class); + } + +} diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/WebApplicationServer.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/WebApplicationServer.java index bb3b7a88..21433e1b 100644 --- a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/WebApplicationServer.java +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/WebApplicationServer.java @@ -27,9 +27,7 @@ import fun.asgc.neutrino.core.annotation.Destroy; import fun.asgc.neutrino.core.annotation.Init; import fun.asgc.neutrino.core.context.ApplicationConfig; import fun.asgc.neutrino.core.context.ApplicationRunner; -import fun.asgc.neutrino.core.util.HttpServerUtil; -import fun.asgc.neutrino.core.util.NumberUtil; -import fun.asgc.neutrino.core.util.StringUtil; +import fun.asgc.neutrino.core.util.*; import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.Unpooled; import io.netty.channel.*; @@ -49,7 +47,9 @@ import lombok.extern.slf4j.Slf4j; @Component public class WebApplicationServer implements ApplicationRunner { @Autowired - private ApplicationConfig rootApplicationConfig; + private ApplicationConfig applicationConfig; + @Autowired + private HttpRequestHandler httpRequestHandler; private EventLoopGroup bossGroup; private EventLoopGroup workerGroup; private ServerBootstrap serverBootstrap; @@ -58,7 +58,7 @@ public class WebApplicationServer implements ApplicationRunner { @Init public void init() { - ApplicationConfig.Http http = rootApplicationConfig.getHttp(); + ApplicationConfig.Http http = applicationConfig.getHttp(); if (StringUtil.notEmpty(http.getMaxContentLengthDesc()) && null == http.getMaxContentLength()) { http.setMaxContentLength(NumberUtil.descriptionToSize(http.getMaxContentLengthDesc(), 64 * 1024)); } @@ -66,14 +66,12 @@ public class WebApplicationServer implements ApplicationRunner { this.bossGroup = new NioEventLoopGroup(); this.workerGroup = new NioEventLoopGroup(); this.serverBootstrap = new ServerBootstrap(); + this.initFavicon(); } @Override public void run(String[] args) throws Exception { - ApplicationConfig.Http http = rootApplicationConfig.getHttp(); - if (!http.getContextPath().endsWith("/")) { - http.setContextPath(http.getContextPath() + "/"); - } + ApplicationConfig.Http http = applicationConfig.getHttp(); this.serverBootstrap.group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class) @@ -93,8 +91,8 @@ public class WebApplicationServer implements ApplicationRunner { protected void channelRead0(ChannelHandlerContext context, FullHttpRequest request) throws Exception { String uri = request.uri(); log.debug("http request: {}", uri); - if (uri.startsWith(http.getContextPath())) { - // TODO + if (uri.startsWith(http.getContextPath() + "/") || uri.equals(http.getContextPath())) { + httpRequestHandler.handle(context, request); } else if (uri.equals("/favicon.ico") && null != faviconBytes) { FullHttpResponse fullHttpResponse = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, Unpooled.wrappedBuffer(faviconBytes)); fullHttpResponse.headers().add(HttpHeaderNames.CONTENT_TYPE, "image/x-icon"); @@ -110,6 +108,18 @@ public class WebApplicationServer implements ApplicationRunner { log.info("HTTP服务启动,端口:{} context-path:{}", http.getPort(), http.getContextPath()); } + private void initFavicon() { + if (null == applicationConfig.getHttp().getStaticResource() || CollectionUtil.isEmpty(applicationConfig.getHttp().getStaticResource().getLocations())) { + return; + } + for (String location : applicationConfig.getHttp().getStaticResource().getLocations()) { + this.faviconBytes = FileUtil.readBytes(location.concat("favicon.ico")); + if (null != faviconBytes) { + break; + } + } + } + @Destroy public void destroy() { this.channelFuture.channel().close(); diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/annotation/GetMapping.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/annotation/GetMapping.java new file mode 100644 index 00000000..b7c065f6 --- /dev/null +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/annotation/GetMapping.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * + * @author: aoshiguchen + * @date: 2022/7/15 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE,ElementType.METHOD}) +public @interface GetMapping { + String[] value() default {}; +} diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/annotation/PostMapping.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/annotation/PostMapping.java new file mode 100644 index 00000000..4f092a1d --- /dev/null +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/annotation/PostMapping.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * + * @author: aoshiguchen + * @date: 2022/7/15 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE,ElementType.METHOD}) +public @interface PostMapping { + String[] value() default {}; +} diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/annotation/RestController.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/annotation/RestController.java new file mode 100644 index 00000000..7e6f301a --- /dev/null +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/annotation/RestController.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web.annotation; + +import fun.asgc.neutrino.core.annotation.Component; +import fun.asgc.neutrino.core.annotation.NonIntercept; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author: aoshiguchen + * @date: 2022/7/15 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Component +@NonIntercept +public @interface RestController { + +} diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/exception/WebException.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/exception/WebException.java new file mode 100644 index 00000000..430c24d6 --- /dev/null +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/exception/WebException.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web.exception; + +import fun.asgc.neutrino.core.exception.InternalException; + +/** + * web服务异常 + * @author: aoshiguchen + * @date: 2022/7/15 + */ +public class WebException extends InternalException { + protected String method; + protected Integer code; + private String path; + protected String message; + + public WebException(String method, Integer code, String path, String message) { + super(message); + } + + public WebException(String method, Integer code, String path, String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/exception/WebResourceNotFoundException.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/exception/WebResourceNotFoundException.java new file mode 100644 index 00000000..0821de7c --- /dev/null +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/exception/WebResourceNotFoundException.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web.exception; + +/** + * web资源找不到异常 + * @author: aoshiguchen + * @date: 2022/7/15 + */ +public class WebResourceNotFoundException extends WebException { + + public WebResourceNotFoundException(String method, String path, String message) { + super(method, 404, path, message); + } + + public WebResourceNotFoundException(String method, String path, String message, Throwable cause) { + super(method, 404, path, message, cause); + } +} diff --git a/neutrino-core/src/test/java/fun/asgc/neutrino/core/util/LockUtilTest.java b/neutrino-core/src/test/java/fun/asgc/neutrino/core/util/LockUtilTest.java index e93b74f5..8a03d78f 100644 --- a/neutrino-core/src/test/java/fun/asgc/neutrino/core/util/LockUtilTest.java +++ b/neutrino-core/src/test/java/fun/asgc/neutrino/core/util/LockUtilTest.java @@ -70,8 +70,8 @@ public class LockUtilTest { @Data public static class A { - public A() { - System.out.println("new instance."); - } +// public A() { +// System.out.println("new instance."); +// } } } diff --git a/neutrino-core/src/test/java/fun/asgc/neutrino/core/web/HttpMethodTest.java b/neutrino-core/src/test/java/fun/asgc/neutrino/core/web/HttpMethodTest.java new file mode 100644 index 00000000..40b33cfe --- /dev/null +++ b/neutrino-core/src/test/java/fun/asgc/neutrino/core/web/HttpMethodTest.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web; + +import org.junit.Test; + +/** + * + * @author: aoshiguchen + * @date: 2022/7/15 + */ +public class HttpMethodTest { + + @Test + public void test1() { + HttpMethod method = HttpMethod.of("Get"); + System.out.println(method); + } +} diff --git a/neutrino-proxy-server/src/main/resources/static/favicon.ico b/neutrino-proxy-server/src/main/resources/static/favicon.ico new file mode 100644 index 00000000..474afb8c Binary files /dev/null and b/neutrino-proxy-server/src/main/resources/static/favicon.ico differ