Rust 的 RESTful 框架 rustful

码农软件 · 软件分类 · REST/RESTful项目 · 2019-03-11 06:44:22

软件介绍

rustful 是 Rust 编程语言的一个 RESTful 框架,主要目的是创建一个简单、轻量级的 HTTP 服务应用基础。基于无状态结构,根据路径和 HTTP 方法映射到响应处理器。

示例代码:

//Include rustful_macros during syntax phase to be able to use the macros
#![feature(phase)]
#[phase(plugin)]
extern crate rustful_macros;

extern crate rustful;
extern crate http;
use rustful::{Server, Request, Response};
use http::method::Get;

///Our handler function
fn handler(request: Request, response: &mut Response) {
    //Send something nice to the user
    try_send!(response, "Hello, user! It looks like this server works fine." while "sending hello");
}

fn main() {
    let server = Server::new(8080, router!{"/" => Get: handler});

    //Start the server. All code beyond this point is unreachable
    server.run();
}

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

暗时间

暗时间

刘未鹏 / 电子工业出版社 / 2011-7 / 35.00元

2003年,刘未鹏在杂志上发表了自己的第一篇文章,并开始写博客。最初的博客较短,也较琐碎,并夹杂着一些翻译的文章。后来渐渐开始有了一些自己的心得和看法。总体上在这8年里,作者平均每个月写1篇博客或更少,但从未停止。 刘未鹏说—— 写博客这件事情给我最大的体会就是,一件事情如果你能够坚持做8年,那么不管效率和频率多低,最终总能取得一些很可观的收益。而另一个体会就是,一件事情只要你坚持得足......一起来看看 《暗时间》 这本书的介绍吧!

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

URL 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具