A lightweight .NET package for working with HTTP status codes and status code descriptions.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
cstests
fstests
src
.gitignore
LICENSE
README.md
status.sln

README.md

status

A lightweight .NET package for working with HTTP status codes and status code descriptions.

Installation

Install with dotnet cli:

dotnet add package status

Install with Paket:

paket add status

Usage

This small package was built with both C# and F# in mind. It should feel right at home in either language.

// C#
// Because the package was built as an F# module, there's no using statement. `Status` is just available.

var code = Status.Code.InternalServerError;
int statusCodeAsInt = code.ToInt(); // 500
string description = code.Description; // Internal Server Error

// Or, create a code from an int
var code = Status.Code.FromInt(500);
// F#
open Status

let code = InternalServerError

// Match on the code
let isInternalServerError = function
| InternalServerError -> true
| _ -> false

let description =
    fromInt 500
    |> getDescription
    |> printfn "%s" // Prints "Internal Server Error"

let statusCodeAsInt =
    InternalServerError
    |> toInt
    |> printfn "%i" // Prints 500