Skip to content

Commit

Permalink
Add README
Browse files Browse the repository at this point in the history
  • Loading branch information
JosiahWitt committed Feb 23, 2020
1 parent e0aa0e5 commit 8c39884
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# erkhttp

Allows [`erk`](https://github.com/JosiahWitt/erk) error kinds to embed HTTP Statuses.

[![GoDoc](https://godoc.org/github.com/JosiahWitt/erkhttp?status.svg)](https://godoc.org/github.com/JosiahWitt/erkhttp)
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/JosiahWitt/erkhttp)


## Install
```bash
$ github.com/JosiahWitt/erkhttp
```


## Usage
Embed HTTP Statuses in erk errors:

```go
type ErkItemNotFound {
erk.DefaultKind
erkhttp.StatusNotFound
}
```

Fetch the HTTP Status using [`erkhttp.GetHTTPStatus`](https://pkg.go.dev/github.com/JosiahWitt/erkhttp?tab=doc#GetHTTPStatus):
```go
var ErrItemNotFound = erk.New(ErkItemNotFound{}, "item with key '{{.key}}' was not found")

func main() {
fmt.Println(erkhttp.GetHTTPStatus(ErrItemNotFound)) // Prints 404, true
}
```

0 comments on commit 8c39884

Please sign in to comment.