https://github.com/smoothprogrammer/httpstatcheck
https://github.com/smoothprogrammer/httpstatcheck
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/smoothprogrammer/httpstatcheck
- Owner: smoothprogrammer
- License: mit
- Created: 2024-08-06T07:36:53.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-28T07:18:10.000Z (over 1 year ago)
- Last Synced: 2025-06-07T21:44:51.203Z (8 months ago)
- Language: Go
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# httpstatcheck [](https://pkg.go.dev/github.com/minizilla/httpstatcheck) [](https://github.com/minizilla/httpstatcheck/actions/workflows/main.yaml)
Package httpstatcheck provides wildcard HTTP Status Code checking, e.g. 200 == 2XX.
## Example
```go
var checker httpstatcheck.Checker // The zero value for Checker is an empty rule checker ready to use.
checker.Insert("2XX", "400", "500", "3X1")
checker.Check(200) // true
checker.Check(201) // true
checker.Check(400) // true
checker.Check(401) // false
checker.Check(500) // true
checker.Check(501) // false
checker.Check(300) // true 3X1 will be considered as 3XX
```
## Benchmark with regex
```sh
$ go test -bench=.
goos: linux
goarch: arm64
pkg: github.com/minizilla/httpstatcheck
BenchmarkHTTPStatCheck-4 13465224 84.36 ns/op
BenchmarkRegex-4 10013356 120.2 ns/op
PASS
ok github.com/minizilla/httpstatcheck 2.559s
```