mirror of
https://github.com/amigan/rustypaste-pretty.git
synced 2024-11-21 11:59:48 -05:00
feat(server): add basic HTTP server implementation
This commit is contained in:
parent
2d3151292d
commit
df0d22dcb3
3 changed files with 1854 additions and 2 deletions
1827
Cargo.lock
generated
1827
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -6,6 +6,9 @@ description = "Orhun's obscure pastebin server"
|
|||
authors = ["Orhun Parmaksız <orhunparmaksiz@gmail.com>"]
|
||||
|
||||
[dependencies]
|
||||
actix-web = "3.3.2"
|
||||
env_logger = "0.9.0"
|
||||
log = "0.4.14"
|
||||
|
||||
[profile.dev]
|
||||
opt-level = 0
|
||||
|
|
26
src/main.rs
26
src/main.rs
|
@ -1,3 +1,25 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
#[macro_use] extern crate log;
|
||||
use actix_web::middleware::Logger;
|
||||
use actix_web::{web, App, HttpResponse, HttpServer, Responder};
|
||||
|
||||
async fn index() -> impl Responder {
|
||||
HttpResponse::Ok().body("Hello world!")
|
||||
}
|
||||
|
||||
fn config(cfg: &mut web::ServiceConfig) {
|
||||
cfg.service(
|
||||
web::resource("/")
|
||||
.route(web::get().to(index))
|
||||
.route(web::head().to(|| HttpResponse::MethodNotAllowed())),
|
||||
);
|
||||
}
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
||||
HttpServer::new(|| App::new().wrap(Logger::default()).configure(config))
|
||||
.bind("127.0.0.1:8000")?
|
||||
.workers(4)
|
||||
.run()
|
||||
.await
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue