# Magician **Repository Path**: olived/Magician ## Basic Information - **Project Name**: Magician - **Description**: 此仓库是一个备份仓库,会不定时的从github强制覆盖,导致gitee上的PR记录被覆盖掉,如果您想提交PR并保留记录,建议去github上提交 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: http://magician-io.com - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 8 - **Created**: 2023-08-03 - **Last Updated**: 2023-08-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README

Magician ·

Magician is a small HTTP service package based on Netty that makes it very easy to start an http service, and also supports WebSocket, using annotated configuration Handler. If you want to develop an http service with netty but find it cumbersome, then Magician may help you. ## Running environment JDK11+ --- The Jar package for the maven central library supports at least JDK11, but the source code can support at least jdk8, if you need to run on 8, you can download the latest tag and compile it yourself ## Documentation [https://magician-io.com](https://magician-io.com) ## Example ### Importing dependencies ```xml com.github.yuyenews Magician 2.0.7 org.slf4j slf4j-jdk14 1.7.12 ``` ### Creating an http service Create a Handler ```java @HttpHandler(path="/") public class DemoHandler implements HttpBaseHandler { @Override public void request(MagicianRequest magicianRequest, MagicianResponse response) { // response data magicianRequest.getResponse() .sendJson(200, "{'status':'ok'}"); } } ``` Start the http service ```java Magician.createHttp() .scan("handler所在的包名") .bind(8080); ``` ### Creating WebSocket ```java @WebSocketHandler(path = "/websocket") public class DemoSocketHandler implements WebSocketBaseHandler { @Override public void onOpen(WebSocketSession webSocketSession) { } @Override public void onClose(WebSocketSession webSocketSession) { } @Override public void onMessage(WebSocketSession webSocketSession, byte[] message) { } } ```