Rust 的快速、无样板 Web 框架 Tower-web

码农软件 · 软件分类 · Web框架 · 2019-03-24 08:58:12

软件介绍

Tower-web :Rust 的快速、无样板 Web 框架

Tower Web 介绍:

  • 快速:完全异步,基于TokioHyper构建。

  • 符合人体工程学:Tower-web将HTTP与应用程序逻辑分离,删除所有样板。

  • 适用于Rust stable:稳定。

Tower Web是一个快速的Web框架,旨在删除样板。

目标是将所有HTTP概念与应用程序逻辑分离。使用“普通Rust类型”实现应用程序,Tower Web使用宏来生成必要的粘合剂,以便将应用程序作为HTTP服务提供。 

#[macro_use]
extern crate tower_web;
extern crate tokio;

use tower_web::ServiceBuilder;
use tokio::prelude::*;

/// This type will be part of the web service as a resource.
#[derive(Clone, Debug)]
struct HelloWorld;

/// This will be the JSON response
#[derive(Response)]
struct HelloResponse {
    message: &'static str,
}

impl_web! {
    impl HelloWorld {
        #[get("/")]
        #[content_type("json")]
        fn hello_world(&self) -> Result {
            Ok(HelloResponse {
                message: "hello world",
            })
        }
    }
}

pub fn main() {
    let addr = "127.0.0.1:8080".parse().expect("Invalid address");
    println!("Listening on http://{}", addr);

    ServiceBuilder::new()
        .resource(HelloWorld)
        .run(&addr)
        .unwrap();
}

Tower Web 基于Tokio (Rust并发框架与平台)和Hyper(Rust的HTTP server框架)构建。

Tower Web 框架属于Tokio平台生态重要部分。

Tokio英文站点 https://tokio.rs/

Tokio中文站点https://tokio-zh.github.io

Tokio社区 https://tokio-zh.github.io/community

本文地址:https://codercto.com/soft/d/2031.html

数学建模

数学建模

[美] Frank R.Giordano,Maurice D.Weir,William P.Fox / 机械工业出版社 / 2004-1 / 45.00元

数学建模是用数学方法解决各种实际问题的桥梁。本书分离散建模(第1~9章)和连续建模(第10~13章)两部分介绍了整个建模过程的原理,通过本书的学习,学生将**会在创造性模型和经验模型的构建、模型分析以及模型研究方面进行实践,增强解决问题的能力。 ·论证了离散动力系统,离散优化等技术对现代应用数学的发展的促进作用。 ·在创造性模型和经验模型的构建、模型分析以及模型研究中融入个人项目和小组......一起来看看 《数学建模》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

URL 编码/解码
URL 编码/解码

URL 编码/解码

MD5 加密
MD5 加密

MD5 加密工具