https://github.com/larschri/httpdetour
https://github.com/larschri/httpdetour
http testing
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/larschri/httpdetour
- Owner: larschri
- Created: 2020-12-01T21:45:27.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-09T19:48:58.000Z (almost 5 years ago)
- Last Synced: 2024-06-21T02:08:14.570Z (almost 2 years ago)
- Topics: http, testing
- Language: Go
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HTTP Detour
Synchronous HTTP handling. Create `httpdetour.Chan` and inject it where `http.Handler` or `http.RoundTrip` is expected.
The `httpdetour.Chan` is a channel of request/response pairs that can be handled in a single goroutine. For example inside a test function.
## Install
go get github.com/larschri/httpdetour
## Example
Create a `httpdetour.Chan` and inject it either as `http.Handler` or as `http.RoundTrip`.
```go
handler := httpdetour.NewChan()
server := httptest.NewServer(handler)
r := <-handler
defer r.Close()
// Read r.Request
// Write r.ResponseWriter
```