Skip to content

Files

Latest commit

e77efac · Aug 20, 2019

History

History
130 lines (105 loc) · 4.94 KB

CHANGELOG.md

File metadata and controls

130 lines (105 loc) · 4.94 KB

2019-08

0.4.4

  • Adding the send_async method to the Response object provided to the route handlers. Callers can then perform heavy computations or i/o operations in a separate function or a closure. For example, before this, callers usually write the handler as the following:
pub fn simple_handler(req: &Box<Request>, resp: &mut Box<Response>) {
    // process request to extract info for generating the response body.
    let (meta_data, header): (MetaData, HashMap<String, String>) = preprocess(req);
    resp.with_headers(header);

    // the heavy method will block until all contents are returned
    resp.send(&heavy_method(meta_data));
}

Now with the send_async method, you can rewrite the handler as:

pub fn simple_handler(req: &Box<Request>, resp: &mut Box<Response>) {
    // process request to extract info for generating the response body.
    let (meta_data, header): (MetaData, HashMap<String, String>) = preprocess(req);
    resp.with_headers(header);

    // the heavy method will *NOT* block in this case. The closure's return value 
    // shall be a tuple: 1) the 1st param shall be a `Option<u16>` for any special 
    // status code for the response, and if it's `None`, we will use status code 200 
    // as the default value; 2) the 2nd param shall be a `String` that will comprise
    // the response body. Note that the response generated by this method will be appended
    // to any existing value set to the response body previously.
    resp.send_async(|| (None, heavy_method(meta_data)));
    
    // The above method call is equivalent to the line below: 
    // resp.send_async(|| (Some(200), heavy_method(meta_data)));
}

2019-07

0.4.3

  • This version starts to support use of TLS connections:
extern crate rusty_express;

use rusty_express::prelude::*;
use std::path::PathBuf;

fn main() {
    // define http server now
    let mut config = ServerConfig::new();
    
    // set the path to the tls identity key
    config.set_tls_path("./private/identity.pfx");

    // supply the config to the server
    let mut server = HttpServer::new_with_config(config);
   
    // ... code to add routes and so on ... 
    
    server.listen(8080);
}
  • Fixing bugs in the router when using the static path.
  • Now router also allow callers to define case sensitive routes. The default behavior remains the same, that we will treat all routing path as lower cased.
  • The server-launching callback function will take a struct wrapper for the control message sender, the AsyncController.
  • Now you can also specify the maximum length of the request we shall take per request. This can be a handy tool to prevent client sending arbitrary large payload and exhaust the server resources. For example, you can call config.set_read_limit(512) , or server.config().set_read_limit(512), to constraint a request read size to 512 Byte. If a request exceeds this size limit (which includes headers), we will return a 403 Access Denied error. If setting the limit to 0, or leaving it as default, we will keep reading the request until reaching the end.

2019-04

0.4.2

  • New API to support setup of a static folder location, which will be used to serve files in this folder without naming every available files in the router:
extern crate rusty_express;

use rusty_express::prelude::*;
use std::path::PathBuf;

fn main() {
    // define http server now
    let mut server = HttpServer::new();
    server.set_pool_size(8);
    server.use_static(PathBuf::from(r".\static"));
}

For more examples, please see [examples/static_folder.rs].

2019-01

0.4.1

  • Default read/write timeout to 0, unless specified otherwise
  • More rewrite to boost performance

2019-01

0.4.0

  • Performance improvement to request parser
  • Switching to use crossbeam_channel for async communications in the main connection workflow
  • Fixing various small bugs

2018-10

0.3.6

  • Router has been updated for better performance.
  • Native logger service. More documentation coming in 0.4.0.
  • Next version will be in 0.4.x after updating to the Rust 20118 version and fixing lexical differences.

2018-08

0.3.5

  • Now you can define regular expressions for validating the RequestPath::ExplicitWithParams routes. For example, your parameterized route can now be defined as: /api/:userId(\d{7}) which only allows users with 7 digits IDs. This will help reduce the server burden if the incoming request is trying to guess the parameters.
  • The following config related APIs are changed to be static methods, and you can use them thread-safe now:
Before 0.3.5 After 0.3.5
config.use_default_header(...) ServerConfig::use_default_header(...)
config.set_default_header(...) ServerConfig::set_default_header(...)
config.set_status_page_generator(...) ServerConfig::set_status_page_generator(...)

===================================================

Version updates prior to 0.3.5 have been omitted from this log.