Tower-web 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
Tower-web 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
Tower-web 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 Apache
开发语言 Rust
操作系统 跨平台
软件类型 开源软件
所属分类 Web应用开发Web框架
开源组织
地区 不详
投 递 者 krircc
适用人群 未知
收录时间 2018-10-18

软件简介

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

展开阅读全文

代码

的 Gitee 指数为
超过 的项目

评论

点击引领话题📣
暂无内容
发表了博客
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
发表了问答
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
暂无内容
0 评论
22 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部