Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name = "rouille"
version = "3.6.2"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
license = "MIT/Apache-2.0"
license = "MIT OR Apache-2.0"
edition = "2021"
repository = "https://github.com/tomaka/rouille"
documentation = "http://docs.rs/rouille"
description = "High-level idiomatic web framework."
Expand Down
12 changes: 3 additions & 9 deletions examples/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,11 @@
// notice may not be copied, modified, or distributed except
// according to those terms.

#[macro_use]
extern crate rouille;
extern crate postgres;
extern crate serde;
#[macro_use]
extern crate serde_derive;

use std::sync::Mutex;

use postgres::{Client, NoTls, Transaction};

use rouille::router;
use rouille::try_or_400;
use rouille::Request;
use rouille::Response;

Expand Down Expand Up @@ -109,7 +103,7 @@ fn note_routes(request: &Request, db: &mut Transaction) -> Response {
(GET) (/notes) => {
// This route returns the list of notes. We perform the query and output it as JSON.

#[derive(Serialize)]
#[derive(serde_derive::Serialize)]
struct Elem { id: String }

let mut out = Vec::new();
Expand Down
2 changes: 0 additions & 2 deletions examples/git-http-backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
// notice may not be copied, modified, or distributed except
// according to those terms.

extern crate rouille;

use rouille::cgi::CgiRun;
use std::env;
use std::io;
Expand Down
4 changes: 1 addition & 3 deletions examples/hello-world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// according to those terms.

#![allow(unreachable_code)]
#[macro_use]
extern crate rouille;

fn main() {
println!("Now listening on localhost:8000");
Expand All @@ -29,7 +27,7 @@ fn main() {
// the `router!` macro is an expression whose value is the `Response` built by the block
// that was called. Since `router!` is the last piece of code of this closure, the
// `Response` is then passed back to the `start_server` function and sent to the client.
router!(request,
rouille::router!(request,
(GET) (/) => {
// If the request's URL is `/`, we jump here.
// This block builds a `Response` object that redirects to the `/hello/world`.
Expand Down
8 changes: 5 additions & 3 deletions examples/login-session.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#![allow(dead_code)]
#![allow(unreachable_code)]
#[macro_use]
extern crate rouille;

use rouille::post_input;
use rouille::router;
use rouille::try_or_400;
use rouille::Request;
use rouille::Response;
use std::collections::HashMap;
Expand Down Expand Up @@ -95,7 +97,7 @@ fn main() {
fn handle_route(request: &Request, session_data: &mut Option<SessionData>) -> Response {
// First we handle the routes that are always accessible and always the same, no matter whether
// the user is logged in or not.
router!(request,
rouille::router!(request,
(POST) (/login) => {
// This is the route that is called when the user wants to log in.

Expand Down
2 changes: 0 additions & 2 deletions examples/php.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
// notice may not be copied, modified, or distributed except
// according to those terms.

extern crate rouille;

use rouille::cgi::CgiRun;
use std::process::Command;

Expand Down
2 changes: 0 additions & 2 deletions examples/reverse-proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
// notice may not be copied, modified, or distributed except
// according to those terms.

extern crate rouille;

fn main() {
// This example shows how to create a reverse proxy with rouille.

Expand Down
7 changes: 4 additions & 3 deletions examples/simple-form.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#[macro_use]
extern crate rouille;

use std::io;

use rouille::post_input;
use rouille::router;
use rouille::try_or_400;

fn main() {
// This example demonstrates how to handle HTML forms.

Expand Down
2 changes: 0 additions & 2 deletions examples/static-files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
// notice may not be copied, modified, or distributed except
// according to those terms.

extern crate rouille;

use rouille::Response;

fn main() {
Expand Down
5 changes: 2 additions & 3 deletions examples/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
// notice may not be copied, modified, or distributed except
// according to those terms.

#[macro_use]
extern crate rouille;

use std::thread;

use rouille::router;
use rouille::try_or_400;
use rouille::websocket;
use rouille::Response;

Expand Down
5 changes: 1 addition & 4 deletions rouille-multipart/examples/hyper_client.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
extern crate hyper;
extern crate multipart;

use hyper::client::Request;
use hyper::method::Method;
use hyper::net::Streaming;

use multipart::client::Multipart;
use rouille_multipart::client::Multipart;

use std::io::Read;

Expand Down
5 changes: 1 addition & 4 deletions rouille-multipart/examples/hyper_reqbuilder.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
extern crate hyper;
extern crate multipart;

use hyper::Client;

use multipart::client::lazy::Multipart;
use rouille_multipart::client::lazy::Multipart;

fn main() {
let mut binary = "Hello world in binary!".as_bytes();
Expand Down
9 changes: 3 additions & 6 deletions rouille-multipart/examples/hyper_server.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
extern crate hyper;
extern crate multipart;

use hyper::server::response::Response as HyperResponse;
use hyper::server::{Handler, Request, Response, Server};
use hyper::status::StatusCode;
use multipart::mock::StdoutTee;
use multipart::server::hyper::{HyperRequest, MultipartHandler, Switch};
use multipart::server::{Entries, Multipart, SaveResult};
use rouille_multipart::mock::StdoutTee;
use rouille_multipart::server::hyper::{HyperRequest, MultipartHandler, Switch};
use rouille_multipart::server::{Entries, Multipart, SaveResult};
use std::io;

struct NonMultipart;
Expand Down
7 changes: 2 additions & 5 deletions rouille-multipart/examples/iron.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
extern crate iron;
extern crate multipart;

extern crate env_logger;

use iron::prelude::*;
use iron::status;
use multipart::mock::StdoutTee;
use multipart::server::{Entries, Multipart, SaveResult};
use rouille_multipart::mock::StdoutTee;
use rouille_multipart::server::{Entries, Multipart, SaveResult};
use std::io::{self, Write};

fn main() {
Expand Down
7 changes: 2 additions & 5 deletions rouille-multipart/examples/iron_intercept.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
extern crate iron;
extern crate multipart;

use iron::prelude::*;

use multipart::server::iron::Intercept;
use multipart::server::Entries;
use rouille_multipart::server::iron::Intercept;
use rouille_multipart::server::Entries;

fn main() {
// We start with a basic request handler chain.
Expand Down
9 changes: 3 additions & 6 deletions rouille-multipart/examples/nickel.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
extern crate multipart;
extern crate nickel;

use nickel::status::StatusCode;
use nickel::{Action, HttpRouter, MiddlewareResult, Nickel, Request, Response};
use std::io::{self, Write};

use multipart::mock::StdoutTee;
use multipart::server::nickel::MultipartBody;
use multipart::server::{Entries, SaveResult};
use rouille_multipart::mock::StdoutTee;
use rouille_multipart::server::nickel::MultipartBody;
use rouille_multipart::server::{Entries, SaveResult};

fn handle_multipart<'mw>(req: &mut Request, mut res: Response<'mw>) -> MiddlewareResult<'mw> {
match (*req).multipart_body() {
Expand Down
7 changes: 2 additions & 5 deletions rouille-multipart/examples/tiny_http.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
extern crate multipart;
extern crate tiny_http;

use multipart::mock::StdoutTee;
use multipart::server::{Entries, Multipart, SaveResult};
use rouille_multipart::mock::StdoutTee;
use rouille_multipart::server::{Entries, Multipart, SaveResult};
use std::io::{self, Cursor, Write};
use tiny_http::{Request, Response, StatusCode};
fn main() {
Expand Down
5 changes: 1 addition & 4 deletions rouille-multipart/src/bin/form_test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
extern crate hyper;
extern crate multipart;

use multipart::server::Multipart;
use rouille_multipart::server::Multipart;

use hyper::header::ContentType;
use hyper::server::*;
Expand Down
4 changes: 0 additions & 4 deletions rouille-multipart/src/client/lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ impl<'a> Into<io::Error> for LazyError<'a, io::Error> {
}

impl<'a, E: Error> Error for LazyError<'a, E> {
fn description(&self) -> &str {
self.error.description()
}

fn cause(&self) -> Option<&dyn Error> {
Some(&self.error)
}
Expand Down
14 changes: 7 additions & 7 deletions rouille-multipart/src/local_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
use mock::{ClientRequest, HttpBuffer};
use crate::mock::{ClientRequest, HttpBuffer};

use server::{FieldHeaders, MultipartField, ReadEntry};
use crate::server::{FieldHeaders, MultipartField, ReadEntry};

use mime::Mime;

Expand Down Expand Up @@ -226,7 +226,7 @@ impl fmt::Debug for PrintHex {

macro_rules! do_test (
($client_test:ident, $server_test:ident) => (
::init_log();
crate::init_log();

info!("Client Test: {:?} Server Test: {:?}", stringify!($client_test),
stringify!($server_test));
Expand Down Expand Up @@ -344,7 +344,7 @@ fn gen_bytes() -> Vec<u8> {
}

fn test_client(test_fields: &TestFields) -> HttpBuffer {
use client::Multipart;
use crate::client::Multipart;

let request = ClientRequest::default();

Expand Down Expand Up @@ -392,7 +392,7 @@ fn test_client(test_fields: &TestFields) -> HttpBuffer {
}

fn test_client_lazy(test_fields: &TestFields) -> HttpBuffer {
use client::lazy::Multipart;
use crate::client::lazy::Multipart;

let mut multipart = Multipart::new();

Expand Down Expand Up @@ -441,7 +441,7 @@ fn test_client_lazy(test_fields: &TestFields) -> HttpBuffer {
}

fn test_server(buf: HttpBuffer, fields: &mut TestFields) {
use server::Multipart;
use crate::server::Multipart;

let server_buf = buf.for_server();

Expand All @@ -461,7 +461,7 @@ fn test_server(buf: HttpBuffer, fields: &mut TestFields) {
}

fn test_server_entry_api(buf: HttpBuffer, fields: &mut TestFields) {
use server::Multipart;
use crate::server::Multipart;

let server_buf = buf.for_server();

Expand Down
14 changes: 7 additions & 7 deletions rouille-multipart/src/server/boundary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@

self.source.consume(consume_amt);

if cfg!(debug_assertions) {}

Check warning on line 211 in rouille-multipart/src/server/boundary.rs

View workflow job for this annotation

GitHub Actions / Lint & Format (rustls)

this `if` branch is empty

Check warning on line 211 in rouille-multipart/src/server/boundary.rs

View workflow job for this annotation

GitHub Actions / Lint & Format (default)

this `if` branch is empty

Check warning on line 211 in rouille-multipart/src/server/boundary.rs

View workflow job for this annotation

GitHub Actions / Lint & Format (ssl)

this `if` branch is empty

self.search_idx = 0;

Expand Down Expand Up @@ -310,7 +310,7 @@

#[test]
fn test_boundary() {
::init_log();
crate::init_log();

debug!("Testing boundary (no split)");

Expand Down Expand Up @@ -356,7 +356,7 @@

#[test]
fn test_split_boundary() {
::init_log();
crate::init_log();

debug!("Testing boundary (split)");

Expand Down Expand Up @@ -406,7 +406,7 @@

#[test]
fn test_empty_body() {
::init_log();
crate::init_log();

// empty body contains closing boundary only
let mut body: &[u8] = b"--boundary--";
Expand All @@ -428,7 +428,7 @@

#[test]
fn test_leading_crlf() {
::init_log();
crate::init_log();

let mut body: &[u8] = b"\r\n\r\n--boundary\r\n\
asdf1234\
Expand All @@ -455,7 +455,7 @@

#[test]
fn test_trailing_crlf() {
::init_log();
crate::init_log();

let mut body: &[u8] = b"--boundary\r\n\
asdf1234\
Expand Down Expand Up @@ -499,7 +499,7 @@
// https://github.com/abonander/multipart/issues/93#issuecomment-343610587
#[test]
fn test_trailing_lflf() {
::init_log();
crate::init_log();

let mut body: &[u8] = b"--boundary\r\n\
asdf1234\
Expand Down Expand Up @@ -542,7 +542,7 @@
// https://github.com/abonander/multipart/issues/104
#[test]
fn test_unterminated_body() {
::init_log();
crate::init_log();

let mut body: &[u8] = b"--boundary\r\n\
asdf1234\
Expand Down
4 changes: 2 additions & 2 deletions rouille-multipart/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ pub trait HttpRequest {

#[test]
fn issue_104() {
::init_log();
crate::init_log();

use std::io::Cursor;

Expand All @@ -226,7 +226,7 @@ fn issue_104() {

#[test]
fn issue_114() {
::init_log();
crate::init_log();

fn consume_all<R: BufRead>(mut rdr: R) {
loop {
Expand Down
Loading
Loading