dawedawe / FsHttp

A lightweight F# HTTP library by @ronaldschlenker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

logo

FsHttp is a .Net HTTP client library for C# and F#. It aims for describing and executing HTTP requests in convenient ways that can be used in production and interactive environments.

The design principle behind FsHttp is:

Specify common HTTP requests in a most convenient and readable way, while still being able to access the underlying .Net Http representations for covering unusual cases.

FsHttp is developed and maintained by @ronaldschlenker and @dawedawe. Feel free to leave us a message.

NuGet Badge build status

A Simple Example

An example in F#:

#r "nuget: FsHttp"

open FsHttp

http {
    POST "https://reqres.in/api/users"
    CacheControl "no-cache"
    body
    jsonSerialize
        {|
            name = "morpheus"
            job = "leader"
        |}
}
|> Request.send

An example in C#:

#r "nuget: FsHttp"

using FsHttp.CSharp;

await "https://reqres.in/api/users".Post()
    .CacheControl("no-cache")
    .Body()
    .JsonSerialize(new
        {
            name = "morpheus",
            job = "leader"
        }
    )
    .SendAsync();

Documentation

Release Notes / Migrating to new versions

GitHub

Please see FsHttp on GitHub.

Building

.Net SDK:

You need to have the latest .Net SDK installed, which is specified in ./global.json.

Build Tasks

There is a F# build script (./build.fsx) that can be used to perform several build tasks from command line.

For common tasks, there are powershell files located in the repo root:

  • ./test.ps1: Runs all tests (sources in ./src/Tests).
    • You can pass args to this task. E.g. for executing only some tests: ./test.ps1 --filter Name~'Response Decompression'
  • ./docu.ps1: Rebuilds the FsHttp documentation site (sources in ./src/docs; output goes to ./docs).
  • ./docu-watch.ps1: Run it if you are working on the documentation sources, and want to see the result in a browser.
  • ./publish.ps1: Publishes all packages (FsHttp and it's integration packages for Newtonsoft and FSharp.Data) to NuGet.
    • Always have a look at ./src/Directory.Build.props and keep the file up-to-date.

Credits

  • Parts of the code is taken from the HTTP utilities of FSharp.Data.
  • Credits to all critics, supporters, contributors, promoters, users, and friends.

About

A lightweight F# HTTP library by @ronaldschlenker

License:Apache License 2.0


Languages

Language:F# 97.2%Language:C# 2.5%Language:PowerShell 0.3%