Skip to content

Releases: co-rs/mco-http

v0.1.16

18 Feb 15:41
Compare
Choose a tag to compare

v0.1.16

  • unix system for non-blocking io don't need flush

v0.1.15

17 Feb 12:22
Compare
Choose a tag to compare

v0.1.15

  • Request add rust pub extra: Extensions
  • MiddleWare change to use rust fn handle(&self, req: &mut Request, res: &mut Option<Response>)

v0.1.13

14 Feb 09:22
Compare
Choose a tag to compare

v0.1.13

  • add method read_json
    for example
use cogo_http::json::read_json;
use cogo_http::server::{Request, Response};

fn hello(mut req: Request, res: Response) {
    let json_data: serde_json::Value = read_json(&mut req).unwrap();
    println!("req:{:?}",json_data);
    res.send(json_data.to_string().as_bytes()).unwrap();
}

v0.1.12

12 Feb 05:40
Compare
Choose a tag to compare

v0.1.12

  • fix socket error

v0.1.10

10 Feb 14:29
Compare
Choose a tag to compare

v0.1.10

  • fix some bugs
  • fix performance

v0.1.9

10 Feb 09:52
Compare
Choose a tag to compare

v0.1.9

  • fix performance

v0.1.8

08 Feb 20:51
Compare
Choose a tag to compare

v0.1.8

  • use std::mem::transmute_copy replace stream.clone(). so This change can improve performance

v0.1.7

06 Feb 21:14
Compare
Choose a tag to compare

v0.1.7

  • fix route

v0.1.6

06 Feb 16:42
Compare
Choose a tag to compare

v0.1.6

  • add route mod
use cogo_http::query::read_query;
use cogo_http::route::Route;
use cogo_http::server::{Request, Response};
use cogo_http::route::MiddleWare;

fn js(req: Request, res: Response) {
    res.send("{\"name\":\"joe\"}".as_bytes()).unwrap();
}

fn hello(req: Request, res: Response) {
    let param = read_query(&req.uri.to_string());
    res.send(format!("{:?}", param).as_bytes()).unwrap();
}

// MiddleWare
#[derive(Debug)]
pub struct MyMiddleWare {}

impl MiddleWare for MyMiddleWare {
    fn handle(&self, req: &mut Request, res: &mut Response) -> bool {
        println!("hello MiddleWare!");
        //return true is done
        return false;
    }
}

fn main() {
    env_logger::init().unwrap();

    let mut route = Route::new();
    route.add_middleware(MyMiddleWare {});
    route.handle_fn("/", hello);
    route.handle_fn("/js", js);
    route.handle_fn("/fn", |req: Request, res: Response| {
        res.send(format!("fn").as_bytes());
    });

    let _listening = cogo_http::Server::http("0.0.0.0:3000").unwrap()
        .handle(route);
    println!("Listening on http://127.0.0.1:3000");
    println!("please click http://127.0.0.1:3000/?q=query_info&b=123");
    println!("please click http://127.0.0.1:3000/js");
    println!("please click http://127.0.0.1:3000/fn");
}

v0.1.5

06 Feb 14:06
Compare
Choose a tag to compare

v0.1.5

  • add path decode
  • add query decode