Skip to content

Instantly share code, notes, and snippets.

@mayankchoubey
Created February 19, 2024 00:30
Show Gist options
  • Save mayankchoubey/d326fdaf230d07cb8dec8fe7583aba4e to your computer and use it in GitHub Desktop.
Save mayankchoubey/d326fdaf230d07cb8dec8fe7583aba4e to your computer and use it in GitHub Desktop.
Rocket vs Actix vs Axum vs Warp vs Gotham
use actix_web::{get, App, HttpServer, Responder};
use uuid::Uuid;
#[get("/")]
async fn index() -> impl Responder {
return "Hello ".to_owned() + &Uuid::new_v4().to_string();
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| App::new().service(index))
.bind(("127.0.0.1", 3000))?
.run()
.await
}
use axum::{
routing::get,
Router,
};
use uuid::Uuid;
#[tokio::main]
async fn main() {
let app = Router::new().route("/", get(|| async {
"Hello ".to_owned() + &Uuid::new_v4().to_string()
}));
let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
.await
.unwrap();
axum::serve(listener, app).await.unwrap();
}
use gotham::prelude::*;
use gotham::router::{build_simple_router, Router};
use gotham::state::State;
use uuid::Uuid;
pub fn say_hello(state: State) -> (State, String) {
(state, "Hello ".to_owned() + &Uuid::new_v4().to_string())
}
fn router() -> Router {
build_simple_router(|route| {
route.get("/").to(say_hello);
})
}
pub fn main() {
let addr = "127.0.0.1:3000";
gotham::start(addr, router()).unwrap();
}
#[macro_use] extern crate rocket;
use uuid::Uuid;
#[get("/")]
fn index() -> String {
return "Hello ".to_owned() + &Uuid::new_v4().to_string();
}
#[launch]
fn rocket() -> _ {
rocket::build().mount("/", routes![index])
}
use warp::Filter;
use uuid::Uuid;
#[tokio::main]
async fn main() {
let routes = warp::path::end().map(||
"Hello ".to_owned() + &Uuid::new_v4().to_string()
);
warp::serve(routes)
.run(([127, 0, 0, 1], 3000))
.await;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment