You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have looked for existing issues (including closed) about this
Bug Report
Version
├── axum v0.6.17
│ ├── axum-core v0.3.4
Platform
Linux homelab 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64 GNU/Linux
Crates
Description
I am try to run my first axum example from readme page.
use axum::{
routing::{get, post},
http::StatusCode,
response::IntoResponse,Json,Router,};use serde::{Deserialize,Serialize};use std::net::SocketAddr;#[tokio::main]asyncfnmain(){// initialize tracing
tracing_subscriber::fmt::init();// build our application with a routelet app = Router::new()// `GET /` goes to `root`.route("/",get(root))// `POST /users` goes to `create_user`.route("/users",post(create_user));// run our app with hyperlet listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();}// basic handler that responds with a static stringasyncfnroot() -> &'static str{"Hello, World!"}asyncfncreate_user(// this argument tells axum to parse the request body// as JSON into a `CreateUser` typeJson(payload):Json<CreateUser>,) -> (StatusCode,Json<User>){// insert your application logic herelet user = User{id:1337,username: payload.username,};// this will be converted into a JSON response// with a status code of `201 Created`(StatusCode::CREATED,Json(user))}// the input to our `create_user` handler#[derive(Deserialize)]structCreateUser{username:String,}// the output to our `create_user` handler#[derive(Serialize)]structUser{id:u64,username:String,}
But I got error.
error[E0425]: cannot find function `serve` in crate `axum`
--> src/main.rs:25:11
|
25 | axum::serve(listener, app).await.unwrap();
| ^^^^^ not found in `axum`
The text was updated successfully, but these errors were encountered:
Hi @davidpdrsn , the example you provided in the readme should at least run for test, we are not axum developers, if you can't do that then don't provide example code.
Bug Report
Version
├── axum v0.6.17
│ ├── axum-core v0.3.4
Platform
Linux homelab 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64 GNU/Linux
Crates
Description
I am try to run my first axum example from readme page.
But I got error.
The text was updated successfully, but these errors were encountered: