https://github.com/fzdwx/sky
HTTP,WebSocket ... with Netty
https://github.com/fzdwx/sky
http http-server io java netty netty-spring-boot-starter spring-boot spring-boot-websocket tcp websocket
Last synced: 9 months ago
JSON representation
HTTP,WebSocket ... with Netty
- Host: GitHub
- URL: https://github.com/fzdwx/sky
- Owner: fzdwx
- License: apache-2.0
- Created: 2022-03-15T14:34:32.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-12T23:45:34.000Z (over 3 years ago)
- Last Synced: 2025-03-30T09:05:14.943Z (10 months ago)
- Topics: http, http-server, io, java, netty, netty-spring-boot-starter, spring-boot, spring-boot-websocket, tcp, websocket
- Language: Java
- Homepage:
- Size: 919 KB
- Stars: 11
- Watchers: 2
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sky | Netty Based Transport Tool Kit.
🚀 Use sky you can quickly create an http service or websocket service
## Features
- [x] Http Server
- [x] Websocket Server
- [ ] Spring boot starter [in development](https://github.com/fzdwx/sky/issues/11) (已经基本可用)
- [ ] more...
## Showcase
```xml
io.github.fzdwx
sky-http-springboot-starter
0.11.3.2
```
```java
import http.HttpServerRequest;
import sky.starter.UseSkyWebServer;
@SpringBootApplication
@RestController
@UseSkyWebServer
public class BurstServerApplication {
public static void main(String[] args) {
final ConfigurableApplicationContext run = SpringApplication.run(BurstServerApplication.class);
}
// normal request
@GetMapping("hello")
public String hello(@RequestParam String name) {
return "Hello " + name;
}
// Upgrade to websocket
@GetMapping("connect")
public void connect(@RequestParam String name, HttpServerRequest request) {
// Can be authenticated here
// There is no websocket connection established here, the consumption is small,
// and it is adapted to spring's annotations for taking parameters.
request.upgradeToWebSocket(ws->{
// When a connection is successfully established with the client
ws.mountOpen(h -> {
ws.send("Hello " + name);
});
// Process the binary data sent by the client
ws.mountBinary(b -> {
});
// Process the text data sent by the client
ws.mountText(s -> {
});
// For example, read idle or write idle events
ws.mountEvent(e -> {
});
// ...
});
}
}
```