#map #static

bin+lib czh-http-server

A simple http server

4 releases

0.1.3 Dec 4, 2024
0.1.2 Dec 4, 2024
0.1.1 Nov 30, 2024
0.1.0 Nov 30, 2024

#578 in HTTP server

Download history 446/week @ 2024-11-30 115/week @ 2024-12-07 36/week @ 2024-12-14

597 downloads per month

MIT license

3.5MB
783 lines

Contains (WOFF font, 68KB) GeistMonoVF.woff, (WOFF font, 67KB) nextjs-static/src/app/fonts/GeistVF.woff

this is a http server. static map


lib.rs:

czh_http_server

czh_http_server is a simple http server

Example

let mut server  = HttpServer::create_server("localhost", 3000);
   // server.listen();
   server.filter("/home",|req,res| {
       println!("{:#?}","hello i am filterb");
       if req.url() == "/home/abc" {
           res.json("GLALALALALALA");
           return None
       }
       Some((req,res))
   });
   server.map("/file","/Users/dadigua/Desktop/lifetime/app/nextjs-static/dist");

   server.get("/home",|req,mut res| {
       println!("{:#?}",req.url());
       // println!("{:#?}",req.headers());
       println!("{:#?}",req.cookies());
       res.set_cookie("cooooooo", "this is cookie setted by server");
       res.json("hello fetch");
   });
   server.get("/home/abc",|req,res| {
       println!("{:#?}",req.url());
       res.json("hello fetch/ home/abc");
   });
   
   server.post("/post",|mut req,res| {
       match req.json::<Student>() {
           Ok(stu) => {
               println!("{:#?}",stu);
           },
           Err(_) => {
               res.json("error parse json");
               return;
           },
       }
       println!("{:#?}",req.url());
       res.json("hello post");
   });

   let mut route = Route::new();

   route.get("/sayhello", |req, res| {
       // req.url()
       println!("{:#?}",req.url());
       res.json(Student{
           name:"dadigua".to_string(),
           age:18
       });
   });

   server.router("/route",route);
   server.listen();

Dependencies