Giter Site home page Giter Site logo

may_minihttp's People

Contributors

imbios avatar leandros avatar xudong-huang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

may_minihttp's Issues

POST Example

Hi,
I am trying to do a simple POST. I tried this,
match (req.method(), req.path()) { ("GET", "/json") => { rsp.header("Content-Type: application/json"); serde_json::to_writer( BodyWriter(rsp.body_mut()), &HelloMessage { message: "Hello, World!", }, )?; }, ("POST", "/json") => { rsp.header("Content-Type: application/json"); serde_json::to_writer( BodyWriter(rsp.body_mut()), req.data(), )?; }, ("GET", "/plaintext") => { rsp.header("Content-Type: text/plain").body("Hello, World!"); }, _ => { rsp.status_code("404", "Not Found"); }, }

However, I am not able to access the request Body. Do you have any suggestions perhaps ?
Kind regards
Savi

Rust Edition Upgrade

Hi 👋,

I see may_minihttp uses the 2018 edition of rust.
Are there any plans to port to the 2021 edition?
ditto for the examples ?

Anyway, thank you for this crate!

Use "req.body()" and "req.path()" at same time

but there is a error when I use the req.path() and "req.body()" at smae time: borrow of moved value: req

value borrowed here after move

Full code

extern crate may_minihttp;

use may_minihttp::{HttpServer, HttpService, Request, Response};
use serde_json::Value;

#[derive(Clone)]
struct JsonParse;

impl HttpService for JsonParse {
    fn call(&mut self, req: Request, rsp: &mut Response) -> std::io::Result<()> {
        let mut reader = req.body();
        let value: Value = serde_json::from_reader(&mut reader).unwrap();


        let path = req.path();
        let resp: &str = value[req.path()].as_str().unwrap();
        Ok(())
    }
}

fn main() {
    let server = HttpServer(JsonParse).start("0.0.0.0:8080").unwrap();
    server.join().unwrap();
}

build log(only error part)

error[E0382]: borrow of moved value: `req`
  --> src\main.rs:15:20
   |
10 |     fn call(&mut self, req: Request, rsp: &mut Response) -> std::io::Result<()> {
   |                        --- move occurs because `req` has type `may_minihttp::Request<'_, '_, '_>`, which does not implement the `Copy` trait
11 |         let mut reader = req.body();
   |                              ------ `req` moved due to this method call
...
15 |         let path = req.path();
   |                    ^^^ value borrowed here after move
   |

TLS support?

Do you plan to support TLS at some point directly in the library?

Thanks

need a mini http client.

need a mini http client.
像hyper那个框架一样,提供一个基于may的http client可以发起请求,不然又得使用其他的框架了

windows on arm64 support

want arm64 windows plz!

cargo build is wrong at windows arm64 device.:

The following warnings were emitted during compilation:

warning: The MSVC ARM assemblers do not support -D flags

error: failed to run custom build command for `generator v0.7.5`

Caused by:
  process didn't exit successfully: `C:\dev\gh\may_minihttp\target\debug\build\generator-03cf22b39963fe75\build-script-build` (exit code: 1)
  --- stdout
  cargo:rerun-if-changed=src/detail/asm\asm_aarch64_aapcs_pe_masm.asm
  TARGET = Some("aarch64-pc-windows-msvc")
  OPT_LEVEL = Some("0")
  HOST = Some("aarch64-pc-windows-msvc")
  cargo:rerun-if-env-changed=CC_aarch64-pc-windows-msvc
  CC_aarch64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CC_aarch64_pc_windows_msvc
  CC_aarch64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("neon")
  DEBUG = Some("true")
  cargo:rerun-if-env-changed=CFLAGS_aarch64-pc-windows-msvc
  CFLAGS_aarch64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CFLAGS_aarch64_pc_windows_msvc
  CFLAGS_aarch64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:warning=The MSVC ARM assemblers do not support -D flags
  running: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostARM64\\ARM64\\armasm64.exe" "-nologo" "-g" "-o" "C:\\dev\\gh\\may_minihttp\\target\\debug\\build\\generator-f0cc99bf5c1e309c\\out\\src/detail/asm\\asm_aarch64_aapcs_pe_masm.o" "src/detail/asm\\asm_aarch64_aapcs_pe_masm.asm"
  error A2027: can't open file: src/detail/asm\asm_aarch64_aapcs_pe_masm.asm

  exit code: 1

  --- stderr


  error occurred: Command "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostARM64\\ARM64\\armasm64.exe" "-nologo" "-g" "-o" "C:\\dev\\gh\\may_minihttp\\target\\debug\\build\\generator-f0cc99bf5c1e309c\\out\\src/detail/asm\\asm_aarch64_aapcs_pe_masm.o" "src/detail/asm\\asm_aarch64_aapcs_pe_masm.asm" with args "armasm64.exe" did not execute successfully (status code exit code: 1).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.