Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EspHttpServer.handle_get not found #126

Closed
IricBing opened this issue Dec 13, 2022 · 3 comments
Closed

EspHttpServer.handle_get not found #126

IricBing opened this issue Dec 13, 2022 · 3 comments

Comments

@IricBing
Copy link

2022-12-13_17-31

EspHttpServer.handle_get methods not found at EspHttpServer struct when i test http server demo.

build error:

   Compiling http-server v0.1.0 (/home/iric/code/learn/espressif-trainings/intro/http-server)
error: could not compile `http-server` due to 3 previous errors; 2 warnings emitted
warning: unused imports: `io::Write`, `registry::Registry`
  --> examples/http_server.rs:10:20
   |
10 |     http::server::{registry::Registry, Response},
   |                    ^^^^^^^^^^^^^^^^^^
11 |     io::Write,
   |     ^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

error[E0599]: no method named `handle_get` found for struct `EspHttpServer` in the current scope
  --> examples/http_server.rs:31:12
   |
31 |     server.handle_get("/", |_request, response| {
   |            ^^^^^^^^^^ method not found in `EspHttpServer`

error[E0599]: no method named `handle_get` found for struct `EspHttpServer` in the current scope
  --> examples/http_server.rs:41:12
   |
41 |     server.handle_get("/temperature", move |_request, response| {
   |            ^^^^^^^^^^ method not found in `EspHttpServer`

warning: unused import: `Response`
  --> examples/http_server.rs:10:40
   |
10 |     http::server::{registry::Registry, Response},
   |                                        ^^^^^^^^

error: aborting due to 2 previous errors; 2 warnings emitted

@m1racoli
Copy link

Same issue here. After some digging i found the previous implementation of the example, which indeed works. Take a look at the change.

521ba18

This worked for me after all.

use embedded_svc::{
    http::{
        server::{registry::Registry,Response, ResponseWrite},
        Method,
    },
    io::Write,
};

fn main() -> anyhow::Result<()> {
    # ...
    server.set_inline_handler("/", Method::Get, |request, response| {
        let html = index_html();
        let mut writer = response.into_writer(request)?;
        writer.do_write_all(html.as_bytes())?;
        writer.complete()
    })?;

@m1racoli
Copy link

m1racoli commented Dec 24, 2022

I have the suspicion that the http module has not only changed in later versions of embedded-svc, but also is now only available behind the experimental flag. The docs do not show the module, but it is available in the source code.
https://docs.rs/embedded-svc/latest/src/embedded_svc/lib.rs.html#21

@SergioGasquez
Copy link
Member

This was already updated in #135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants