Git Product home page Git Product logo

sky's Introduction

Sky | Netty Based Transport Tool Kit.

🚀 Use sky you can quickly create an http service or websocket service

Features

  • Http Server
  • Websocket Server
  • Spring boot starter in development (已经基本可用)
  • more...

Showcase

<dependency>
  <groupId>io.github.fzdwx</groupId>
  <artifactId>sky-http-springboot-starter</artifactId>
  <version>0.11.3.2</version>
</dependency>
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 -> {

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

sky's People

Contributors

fzdwx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sky's Issues

✨ 支持jdk1.8

目前是用JDK17开发的,预计在0.10.6中换成JDK1.8开发。然后用户可以自己选择1.8以及以上任意版本。

@fzdwx

✨ feat: 开发spring boot starter

result :
兼容正常的spring boot starter web 的一切行为。

step:

  • 1. 一个简单的spring boot starter,引入后能启动一个web服务
  • 2. 兼容@Controller等注解
  • 3. 兼容@RequestBody等参数注入注解
  • 4. 兼容@RestControllerAdvice自定义异常处理
  • 5. 实现所有controller的收集
  • 6. 兼容Spring的/hello/{name}的语法
  • 7. 抽象出DispatchHandler
  • 8. 支持filter(可能兼容不了)
  • 9. todo

nosuport:

  1. 初步发现支持servlet有点困难

参数解析器:

返回值解析器:

  • 1. default result handler(默认返回值解析器,直接返回所有数据)
  • 2. @responsebody handler
  • 3. ResponseEntity 解析
    • 暂时只支持简单的读取http status、header、body(统一转换为json数据)

解析器的类型转换实现?
抽象出了一个ValConvertor,默认使用的是hutool的cn.hutool.core.convert.ConverterRegistry

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.