diff --git a/Cargo.toml b/Cargo.toml index 06af01a..e698d41 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,21 +1,20 @@ [package] name = "Http" version = "0.0.1" -description = "TribuFu Http" -repository = "https://github.com/TribuFu/Http" -authors = ["TribuFu "] +description = "Http Server" +repository = "https://github.com/GuilhermeWerner/Http" license = "MIT" -edition = "2018" +edition = "2021" publish = false [lib] name="Http" crate-type = ["rlib"] -path = "Source/Http.rs" +path = "Source/lib.rs" [[bin]] name="HttpServer" -path = "Source/Main.rs" +path = "Source/main.rs" doc = false [dependencies] diff --git a/Source/Main.rs b/Source/Main.rs index 76a040d..46d95b7 100644 --- a/Source/Main.rs +++ b/Source/Main.rs @@ -1,7 +1,11 @@ -// Copyright (c) TribuFu. All Rights Reserved. - #![allow(non_snake_case)] +use std::net::TcpListener; + fn main() { - Http::Main(); + let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); + + for stream in listener.incoming() { + Http::HandleConnection(stream.unwrap()); + } } diff --git a/Source/Http.rs b/Source/lib.rs similarity index 66% rename from Source/Http.rs rename to Source/lib.rs index 8212210..27dc831 100644 --- a/Source/Http.rs +++ b/Source/lib.rs @@ -1,24 +1,10 @@ -// Copyright (c) TribuFu. All Rights Reserved. - #![allow(non_snake_case)] use std::fs; use std::io::prelude::*; -use std::net::TcpListener; use std::net::TcpStream; -#[doc(hidden)] -pub fn Main() { - let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); - - for stream in listener.incoming() { - let stream = stream.unwrap(); - - HandleConnection(stream); - } -} - -fn HandleConnection(mut stream: TcpStream) { +pub fn HandleConnection(mut stream: TcpStream) { let mut buffer = [0; 1024]; stream.read(&mut buffer).unwrap();