#client-server #synchronous #server #http #client #web

bin+lib http4r-core

Simple, synchronous, symmetric client and server as a function

7 releases

0.0.6 Mar 20, 2022
0.0.5 Mar 17, 2022
0.0.0 Feb 24, 2022

#992 in HTTP server

31 downloads per month

GPL-3.0-or-later

76KB
1.5K SLoC

http4r

Core

The main contract and functionality of http4r.

  • Handler, Server and Client
  • Writing/reading http messages to/from wire
  • Immutable Request, Response, Uri, Headers, Query etc.
  • Supports simple messages, streams, compression and chunked encoding
  • Coming soon: multipart, x-www-form-urlencoded

Philosophy

  • Simplicity:
    • Prefer a simple synchronous abstraction over http
    • Extension by composition not configuration
  • Minimalism:
    • use as few dependencies as possible to reduce surface area, crate size and upgrade complexity
    • do not publish convenience functions etc. rather share recipes in the docs
  • Compatibility:
    • try to maintain backwards compatibility
    • but unlike Rust itself, prefer to break it over keeping a hamstring-ing abstraction
      • to reduce the likelihood of this, do not publish convenience functions as mentioned above!

About

  • http4r is based on Dan's projects utterlyidle and http-handler.rust and http4t by Matt and is based on http4k inspired by Mr Dave and Ivan Sanchez
  • it is based on Server as a Function:
    • composable http handlers implement (Request) -> Response
    • immutable Request, Response, Headers etc
    • zero magic or reflection, stupidly simple and zero dependencies
    • easily test over the wire or rather in-memory
    • can test in-browser (not over the wire!) by compiling your app to WASM so we can write lightning-fast tests for our front end

http4r is a web toolkit Copyright (C) 2021-onwards Tom Shacham

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program (see COPYING). If not, see https://www.gnu.org/licenses/.

Contributing

I'm new to Rust or I'm a bit rusty

Look at the contributing guidelines at http4r

Dependencies

~10MB
~325K SLoC