{"id":13637371,"url":"https://github.com/miketang84/sapper","last_synced_at":"2025-12-12T12:56:11.158Z","repository":{"id":57666260,"uuid":"56665880","full_name":"miketang84/sapper","owner":"miketang84","description":"A lightweight web framework built on hyper, implemented in Rust language.","archived":false,"fork":false,"pushed_at":"2020-03-17T06:40:15.000Z","size":257,"stargazers_count":617,"open_issues_count":7,"forks_count":46,"subscribers_count":26,"default_branch":"master","last_synced_at":"2024-04-14T17:02:14.579Z","etag":null,"topics":[],"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/miketang84.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","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":"2016-04-20T07:34:36.000Z","updated_at":"2024-03-29T17:29:24.000Z","dependencies_parsed_at":"2022-09-26T20:31:43.343Z","dependency_job_id":null,"html_url":"https://github.com/miketang84/sapper","commit_stats":null,"previous_names":["daogangtang/sapper"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miketang84%2Fsapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miketang84%2Fsapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miketang84%2Fsapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miketang84%2Fsapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miketang84","download_url":"https://codeload.github.com/miketang84/sapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284951,"owners_count":20913704,"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":[],"created_at":"2024-08-02T00:01:16.339Z","updated_at":"2025-12-12T12:56:11.110Z","avatar_url":"https://github.com/miketang84.png","language":"Rust","readme":"# Sapper\n\n![](https://travis-ci.org/sappworks/sapper.svg?branch=master)\n \nSapper, a lightweight web framework, written in Rust.\n\nSapper focuses on ergonomic usage and rapid development. It can work with **stable** Rust.\n\nSapper now is based on hyper 0.10.13.\n\n## Tutorial\n\nLook into [json demo](https://github.com/sappworks/sapper_examples/tree/master/json_example), you can learn how to parse http parameters, and return json;\n\nLook into [mvc diesel demo](https://github.com/sappworks/sapper_examples/tree/master/mvc_example), you can learn how to use database, how to render template, and how to redirect.\n\n[English Tutorial](https://github.com/sappworks/sapper/blob/master/docs/Tutorial-en.md)\n\n[中文教程](https://github.com/sappworks/sapper/blob/master/docs/Tutorial-cn.md)\n\n## Import\n\nIn Cargo.toml,\n\n```\n[dependencies]\nsapper = \"0.1\"\n```\n\n## Basic Example\n\nNow, you can boot the example server with:\n\n```\ncd examples/basic/\ncargo build\ncargo run\n```\n\nand open the browser, visit \n\n`http://localhost:1337/`\n\nor\n\n`http://localhost:1337/test`\n\nor any other url to test it.\n\n## Other Examples\n\n1. [tiny](https://github.com/sappworks/sapper/tree/master/examples/tiny)\n2. [init_global](https://github.com/sappworks/sapper/tree/master/examples/init_global)\n3. [query params](https://github.com/sappworks/sapper_query/tree/master/examples/basic)\n4. [body params](https://github.com/sappworks/sapper_body/tree/master/examples/basic)\n5. [session](https://github.com/sappworks/sapper_session/tree/master/examples/basic)\n6. [template rendering](https://github.com/sappworks/sapper_tmpl/tree/master/examples/basic)\n7. [simple logger](https://github.com/sappworks/sapper_logger/tree/master/examples/basic)\n8. [response json](https://github.com/sappworks/sapper_examples/tree/master/json_example)\n10. [mvc diesel demo](https://github.com/sappworks/sapper_examples/tree/master/mvc_example)\n \n11.  more continued...\n\n## Basic Benchmark\n\n```\nmike@mike-Vostro-3653:~/works2/wrk$ uname -a\nLinux mike-Vostro-3653 4.10.0-21-generic #23-Ubuntu SMP Fri Apr 28 16:14:22 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux\n\n\nmike@mike-Vostro-3653:~/works2/wrk$ cat /proc/cpuinfo \nprocessor\t: 0\nvendor_id\t: GenuineIntel\ncpu family\t: 6\nmodel\t\t: 94\nmodel name\t: Intel(R) Core(TM) i3-6100 CPU @ 3.70GHz\ncpu MHz\t\t: 832.183\ncache size\t: 3072 KB\nbogomips\t: 7392.00\n...\n\n\nmike@mike-Vostro-3653:~/works2/sapper/examples/tiny$ cargo run --release\n    Finished release [optimized] target(s) in 36.27 secs\n     Running `target/release/tiny`\nListening on http://127.0.0.1:1337\n\noutput: hello, world!\n\n\nmike@mike-Vostro-3653:~/works2/wrk$ ./wrk -t2 -c100 -d30s http://127.0.0.1:1337\nRunning 30s test @ http://127.0.0.1:1337\n  2 threads and 100 connections\n  Thread Stats   Avg      Stdev     Max   +/- Stdev\n    Latency    21.73us  139.92us  16.02ms   99.87%\n    Req/Sec   235.94k    26.75k  259.73k    76.33%\n  7045973 requests in 30.04s, 598.04MB read\nRequests/sec: 234536.10\nTransfer/sec:     19.91MB\n```\n\n## Features\n\n- Sapper supplies only basic framework;\n- Three level granularity (global, module, function handler) middleware controller and unified middleware presentation; \n- Typesafe abstraction, keep the same spirit with hyper;\n- For easy using, will supply some convenient macros to help write business logics;\n- Global object cross requests;\n\n## Philosophy\n\nTyped, hierarchical control, and middlewares.\n\n\n### Typed\n\nIn Sapper, nearly every important thing is a `Type`. They are:\n\n- Each module is a type, different modules are different types;\n- Every middleware supplies some (0 to n) types for handler getting values;\n- Inherited from hyper's typed spirit, all headers, mime and so on should use types for manipulation. \n\n### Hierarchical Control\n\n- Sapper forces you to put router in each module (in main.rs, you can not write it, no space left for you to write);\n- Sapper forces you to seperate the router binding and the handler realization;\n- Sapper's plugin processor can be used in app level wrapper, module level wrapper, and each handler. These three level hierarchical controls make it flexible to construct your business.\n\n### Middlewares\n\nSapper's core contains only router system, request and response definitions, middleware system, and some other basic facilities. Nearly all practical features, such as query parameter, body parameter, cookie, session, json, xml, orm..., are supplied by the corresponding middlewares.\n\nSapper's middleware is very easy to write. One rust module realized a function on the prototype of \n\n```rust\nfn (\u0026mut Request) -\u003e Result\u003c()\u003e;  // before plugin\nfn (\u0026Request, \u0026mut Response) -\u003e Result\u003c()\u003e; // after plugin\n```\n\ncan be thought as Sapper's middleware. Sample middleware: [sapper_query](https://github.com/sappworks/sapper_query).\n\n## TODO\n\n1. [X] QueryParams (x-www-form-urlencoded);\n2. [X] BodyParams (x-www-form-urlencoded);\n3. [X] BodyJsonParams;\n3. [X] Basic static file serving for dev;\n5. [X] Global object shared cross requests;\n6. [X] Macros;\n4. [ ] Multipart;\n\n\n\n## Middlewares\n\n- [sapper_query](https://github.com/sappworks/sapper_query)  parsing query string for req;\n- [sapper_body](https://github.com/sappworks/sapper_body) parsing body parameters for req, including url form encoded, json type, json to struct macro;\n- [sapper_logger](https://github.com/sappworks/sapper_logger) record request and caculate its time;\n- [sapper_session](https://github.com/sappworks/sapper_session) a cookie plugin, and else supply a helper set_cookie function;\n- [sapper_tmpl](https://github.com/sappworks/sapper_tmpl) use tera to render template;\n\n\n## Related Projects\n\nThanks to these projects below:\n\n- [hyper](https://github.com/hyperium/hyper) Sapper is based on hyper mio branch;\n- [iron](https://github.com/iron/iron) Sapper learns many designs from iron;\n- [router](https://github.com/iron/router) Sapper steals router about code from it;\n- [recognizer](https://github.com/conduit-rust/route-recognizer.rs) Sapper uses this route recognizer;\n\n\n## License\n\nMIT\n","funding_links":[],"categories":["Libraries","库 Libraries"],"sub_categories":["Web programming","网络编程 Web programming"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiketang84%2Fsapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiketang84%2Fsapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiketang84%2Fsapper/lists"}