{"id":18616695,"url":"https://github.com/sile/fibers_http_server","last_synced_at":"2025-04-11T01:32:03.783Z","repository":{"id":57628935,"uuid":"125169312","full_name":"sile/fibers_http_server","owner":"sile","description":"A tiny HTTP/1.1 server framework for Rust","archived":false,"fork":false,"pushed_at":"2024-06-15T06:24:08.000Z","size":59,"stargazers_count":8,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T07:12:40.259Z","etag":null,"topics":["asynchronous","http","rust","server"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sile.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-14T07:00:17.000Z","updated_at":"2024-10-18T06:57:37.000Z","dependencies_parsed_at":"2022-09-26T20:12:12.033Z","dependency_job_id":null,"html_url":"https://github.com/sile/fibers_http_server","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Ffibers_http_server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Ffibers_http_server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Ffibers_http_server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Ffibers_http_server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sile","download_url":"https://codeload.github.com/sile/fibers_http_server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248190548,"owners_count":21062285,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asynchronous","http","rust","server"],"created_at":"2024-11-07T03:37:39.298Z","updated_at":"2025-04-11T01:32:03.486Z","avatar_url":"https://github.com/sile.png","language":"Rust","readme":"fibers_http_server\n==================\n\n[![fibers_http_server](https://img.shields.io/crates/v/fibers_http_server.svg)](https://crates.io/crates/fibers_http_server)\n[![Documentation](https://docs.rs/fibers_http_server/badge.svg)](https://docs.rs/fibers_http_server)\n[![Build Status](https://travis-ci.org/sile/fibers_http_server.svg?branch=master)](https://travis-ci.org/sile/fibers_http_server)\n[![Code Coverage](https://codecov.io/gh/sile/fibers_http_server/branch/master/graph/badge.svg)](https://codecov.io/gh/sile/fibers_http_server/branch/master)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\nA tiny HTTP/1.1 server framework for Rust.\n\n[Documentation](https://docs.rs/fibers_http_server)\n\nExamples\n---------\n\n```rust\nuse std::io::{Read, Write};\nuse std::net::TcpStream;\nuse std::thread;\nuse std::time::Duration;\nuse bytecodec::bytes::Utf8Encoder;\nuse bytecodec::value::NullDecoder;\nuse fibers::{Executor, Spawn, InPlaceExecutor};\nuse fibers_http_server::{HandleRequest, Reply, Req, Res, ServerBuilder, Status};\nuse futures::future::{ok, Future};\nuse httpcodec::{BodyDecoder, BodyEncoder};\n\n// Request handler\nstruct Hello;\nimpl HandleRequest for Hello {\n    const METHOD: \u0026'static str = \"GET\";\n    const PATH: \u0026'static str = \"/hello\";\n\n    type ReqBody = ();\n    type ResBody = String;\n    type Decoder = BodyDecoder\u003cNullDecoder\u003e;\n    type Encoder = BodyEncoder\u003cUtf8Encoder\u003e;\n    type Reply = Reply\u003cSelf::ResBody\u003e;\n\n    fn handle_request(\u0026self, _req: Req\u003cSelf::ReqBody\u003e) -\u003e Self::Reply {\n        Box::new(ok(Res::new(Status::Ok, \"hello\".to_owned())))\n    }\n}\n\nlet addr = \"127.0.0.1:14758\".parse().unwrap();\n\n// HTTP server\nthread::spawn(move || {\n    let executor = InPlaceExecutor::new().unwrap();\n    let mut builder = ServerBuilder::new(addr);\n    builder.add_handler(Hello).unwrap();\n    let server = builder.finish(executor.handle());\n    executor.spawn(server.map_err(|e| panic!(\"{}\", e)));\n    executor.run().unwrap()\n});\nthread::sleep(Duration::from_millis(100));\n\n// HTTP client\nlet mut client = TcpStream::connect(addr).unwrap();\nclient\n    .write_all(b\"GET /hello HTTP/1.1\\r\\nContent-Length: 0\\r\\n\\r\\n\")\n    .unwrap();\nthread::sleep(Duration::from_millis(100));\n\nlet mut buf = [0; 1024];\nlet size = client.read(\u0026mut buf).unwrap();\nassert_eq!(\n    \u0026buf[..size],\n    b\"HTTP/1.1 200 OK\\r\\nContent-Length: 5\\r\\n\\r\\nhello\".as_ref()\n);\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsile%2Ffibers_http_server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsile%2Ffibers_http_server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsile%2Ffibers_http_server/lists"}