Rust 2018 the web framework examples
This commit is contained in:
parent
6c2b5a9aa9
commit
07ca29aa55
1 changed files with 7 additions and 24 deletions
|
@ -21,12 +21,7 @@ maud = { version = "*", features = ["actix-web"] }
|
||||||
Actix request handlers can use a `Markup` that implements the `actix_web::Responder` trait.
|
Actix request handlers can use a `Markup` that implements the `actix_web::Responder` trait.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
#![feature(proc_macro_non_items)]
|
#![feature(proc_macro_hygiene)]
|
||||||
#![feature(use_extern_macros)]
|
|
||||||
|
|
||||||
extern crate actix;
|
|
||||||
extern crate actix_web;
|
|
||||||
extern crate maud;
|
|
||||||
|
|
||||||
use maud::{html, Markup};
|
use maud::{html, Markup};
|
||||||
use actix_web::{App, server, Path, http::Method};
|
use actix_web::{App, server, Path, http::Method};
|
||||||
|
@ -67,11 +62,7 @@ maud = { version = "*", features = ["iron"] }
|
||||||
With this feature enabled, you can then build a `Response` from a `Markup` object directly. Here's an example application using Iron and Maud:
|
With this feature enabled, you can then build a `Response` from a `Markup` object directly. Here's an example application using Iron and Maud:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
#![feature(proc_macro_non_items)]
|
#![feature(proc_macro_hygiene)]
|
||||||
#![feature(use_extern_macros)]
|
|
||||||
|
|
||||||
extern crate iron;
|
|
||||||
extern crate maud;
|
|
||||||
|
|
||||||
use iron::prelude::*;
|
use iron::prelude::*;
|
||||||
use iron::status;
|
use iron::status;
|
||||||
|
@ -106,15 +97,11 @@ maud = { version = "*", features = ["rocket"] }
|
||||||
This adds a `Responder` implementation for the `Markup` type, so you can return the result directly:
|
This adds a `Responder` implementation for the `Markup` type, so you can return the result directly:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
#![feature(plugin)]
|
#![feature(decl_macro)]
|
||||||
#![plugin(rocket_codegen)]
|
#![feature(proc_macro_hygiene)]
|
||||||
#![feature(proc_macro_non_items)]
|
|
||||||
#![feature(use_extern_macros)]
|
|
||||||
|
|
||||||
extern crate maud;
|
|
||||||
extern crate rocket;
|
|
||||||
|
|
||||||
use maud::{html, Markup};
|
use maud::{html, Markup};
|
||||||
|
use rocket::{get, routes};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
#[get("/<name>")]
|
#[get("/<name>")]
|
||||||
|
@ -135,14 +122,10 @@ fn main() {
|
||||||
Unlike with the other frameworks, Rouille doesn't need any extra features at all! Calling `Response::html` on the rendered `Markup` will Just Work®.
|
Unlike with the other frameworks, Rouille doesn't need any extra features at all! Calling `Response::html` on the rendered `Markup` will Just Work®.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
#![feature(proc_macro_non_items)]
|
#![feature(proc_macro_hygiene)]
|
||||||
#![feature(use_extern_macros)]
|
|
||||||
|
|
||||||
extern crate maud;
|
|
||||||
#[macro_use] extern crate rouille;
|
|
||||||
|
|
||||||
use maud::html;
|
use maud::html;
|
||||||
use rouille::Response;
|
use rouille::{Response, router};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
rouille::start_server("localhost:8000", move |request| {
|
rouille::start_server("localhost:8000", move |request| {
|
||||||
|
|
Loading…
Add table
Reference in a new issue