GithubHelp home page GithubHelp logo

wansenai / summer-boot Goto Github PK

View Code? Open in Web Editor NEW
129.0 12.0 26.0 368 KB

Summer Boot (async web framework)

Home Page: https://crates.io/crates/summer-boot

License: Apache License 2.0

Rust 100.00%
cargo rust web framework

summer-boot's Introduction

Summer Boot

A web framework for Rust


Encapsulating tide, combined with the design principles of spring boot. will simplify web development and enable developers to focus more on business API development.

summer_boot::log Logger started
summer_boot::log 
    _____                                       ____              _   
   / ____|                                     |  _ \            | |  
  | (___  _   _ _ __ ___  _ __ ___   ___ _ __  | |_) | ___   ___ | |_ 
   \___ \| | | | '_ ` _ \| '_ ` _ \ / _ \ '__| |  _ < / _ \ / _ \| __|
   ____) | |_| | | | | | | | | | | |  __/ |    | |_) | (_) | (_) | |_ 
  |_____/ \__,_|_| |_| |_|_| |_| |_|\___|_|    |____/ \___/ \___/ \__|
                                                                      
  :: Summer Boot Version::             (1.4.2)                                                                    
 
summer_boot::server::server Server listening on http://0.0.0.0:8080

Quick Start

Cargo.toml:

summer-boot = "1.4.2"

Add resuorce configuration file to src directory

src/resources/application.yml

profiles:
  active: test

src/resources/application-test.yml

server:
  port: 8080
  context_path: /

src/main.rs

use serde::Deserialize;
use summer_boot::{Request, Result};
use summer_boot::log;

#[derive(Debug, Deserialize)]
struct User {
    name: String,
    age: u16,
}

#[summer_boot::auto_scan]
#[summer_boot::main]
async fn main() {
    summer_boot::run();
}

#[summer_boot::post("/test/api")]
async fn test_api(mut req: Request<()>) -> Result {
    let User { name, age } = req.body_json().await?;
    Ok(format!("Hello, {}!  {} years old", name, age).into())
}

License

Licensed under either of

FOSSA Status

summer-boot's People

Contributors

bors[bot] avatar dependabot[bot] avatar jackmacarthur avatar jzow avatar secretgao avatar wansenai-bot avatar yangandmore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

summer-boot's Issues

Description of Web3 development

Over the past two months, we have been gathering technical knowledge about web3. Unfortunately, there are very few rust demos available for Web3 reference. We have to spend a lot of time doing this, which delays the current optimization of web2. We think it is a bit unreasonable. We will temporarily remove crates that are not used in the next two months and then remove modules related to web3.

We want to gather enough knowledge to complete the current summer boot web2 framework before doing Web3 work, when we will create a new warehouse for development, which is challenging work and will always be open for discussion.

Phase I development task

  • Construction of each module
  • Integrate EVM & IPFS
  • Integrating HTTP and Tokio runtime crates
  • Network monitoring

CI Action Build error

The ci build log
in the log seems to be that the configuration file cannot be loaded.

error: test failed, to rerun pass '-p summer-boot-parent --lib'

running 2 tests
test tests::test_socket ... ok
test tests::test_load_env_conf_mysql ... FAILED

failures:

---- tests::test_load_env_conf_mysql stdout ----
thread 'tests::test_load_env_conf_mysql' panicked at 'Error loading configuration file /work/rust_catalogue/summer-boot/summer-boot-tests/src/resources/app.yml, please check the configuration!', summer-boot-tests/src/lib.rs:40:51
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    tests::test_load_env_conf_mysql

test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Error: Process completed with exit code [101](https://github.com/Jzow/summer-boot/runs/6704014740?check_suite_focus=true#step:4:102).

Remove useless crates reference packages

When conducting cargo check and compilation cargo test, we should note that the console prints many unused scratch warning messages, which should be removed.

example:

warning: unused import: `std::path::Path`
  --> summer-boot-macro/src/lib.rs:20:5
   |
20 | use std::path::Path;
   |     ^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unused import: `fmt::format`
  --> summer-boot-macro/src/lib.rs:21:11
   |
21 | use std::{fmt::format, fs};
   |           ^^^^^^^^^^^

warning: field `name` is never read
  --> summer-boot-macro/src/lib.rs:46:5
   |
45 | struct Name {
   |        ---- field in this struct
46 |     name: String,
   |     ^^^^

Further verification and modification are needed, please note that this is not a bug, it is just an enhancement.

Macro report error code: 5, kind: PermissionDenied

error: custom attribute panicked
  --> example\src\main.rs:11:1
   |
11 | #[summer_boot::auto_scan]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: message: called `Result::unwrap()` on an `Err` value: Os { code: 5, kind: PermissionDenied, message: "拒绝访问。" }

error[E0601]: `main` function not found in crate `example`
  --> example\src\main.rs:21:2
   |
21 | }
   |  ^ consider adding a `main` function to `example\src\main.rs`

For more information about this error, try `rustc --explain E0601`.
error: could not compile `example` (bin "example") due to 2 previous errors

AOP 初步探索以及方案

这块目前team里没有member负责研究,这是个公开讨论的问题,aop实现可以看看 crates.io 是否有一些crate支持

实现接口自动扫描

比如在src/api/下定义了接口,SummerApplication启动后AutoScan自动扫描这些api注入到Socket

Parsing YML needs to be enhanced

At present, we can complete TCP listening by taking the port, but we need to monitor the context_path for parsing

  1. Add context_path support fields
  2. Modify the read code of the loading configuration file and add the read context_path field information

入门案例 依赖少了

use serde::Deserialize;
| ^^^^^ use of undeclared crate or module serde




依赖要添加:
serde = version = "1"

Need to resolve Github CI program compilation errors

The problem with this error stems from the inability to find the UnixListenerclause

CI error log

error[E0432]: unresolved import `super::UnixListener`
 --> summer-boot/src/tcp/parsed.rs:2:5
  |
2 | use super::UnixListener;
  |     ^^^^^^^^^^^^^^^^^^^ no `UnixListener` in `tcp`
  |
help: a similar name exists in the module
  |
2 | use super::ToListener;
  |            ~~~~~~~~~~
help: consider importing one of these items instead
  |
2 | use async_std::os::unix::net::UnixListener;
  |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | use std::os::unix::net::UnixListener;
  |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | use tokio::net::UnixListener;
  |     ~~~~~~~~~~~~~~~~~~~~~~~~

error[E0432]: unresolved import `super::UnixListener`
 --> summer-boot/src/tcp/to_listener_impls.rs:2:5
  |
2 | use super::UnixListener;
  |     ^^^^^^^^^^^^^^^^^^^ no `UnixListener` in `tcp`
  |
help: a similar name exists in the module

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.