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

超预期

超预期

[美] 莱昂纳多·因基莱里、迈卡·所罗门 / 杨波 / 后浪丨江西人民出版社 / 2017-11 / 45.00元

用户体验决定产品成败,只有超预期才能赢得好口碑! 互联网大佬一致推崇的打造爆款产品及服务的核心理念 ................... ※编辑推荐※ ☆ 超预期,才有用户体验,互联网大佬一致推崇的打造爆款产品及服务的核心理念 - 周鸿祎:“什么叫用户体验?超过用户预期才叫 体验!” - 雷军:“口碑的真谛是超越用户的期望值。” - 马化腾:“用户体验,......一起来看看 《超预期》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具