An open API service indexing awesome lists of open source software.

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

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 -> {

});


// ...
});
}
}
```