Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/JMagician/Magician-Http
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.
https://github.com/JMagician/Magician-Http
framework http java magician network nio tcp udp websocket
Last synced: about 5 hours ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/JMagician/Magician-Http
- Owner: JMagician
- License: mit
- Created: 2021-04-10T14:31:28.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-11-19T14:11:10.000Z (about 2 years ago)
- Last Synced: 2025-01-26T07:02:08.482Z (6 days ago)
- Topics: framework, http, java, magician, network, nio, tcp, udp, websocket
- Language: Java
- Homepage: https://magician-io.com
- Size: 353 KB
- Stars: 108
- Watchers: 3
- Forks: 15
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
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.
In addition, we provide many other components that make up a toolkit that will work well for you in blockchain and web development.
## Running environment
JDK8+
## Documentation
[https://magician-io.com](https://magician-io.com)
## Example
### Importing dependencies
```xmlcom.github.yuyenews
Magician
2.0.7org.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) {}
}
```