Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Go Httpbin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Nix
Go Httpbin
Commits
b8eba847
Commit
b8eba847
authored
7 years ago
by
Will McCutchen
Browse files
Options
Downloads
Patches
Plain Diff
Add library use case to README
parent
a4831155
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+31
-0
31 additions, 0 deletions
README.md
with
31 additions
and
0 deletions
README.md
+
31
−
0
View file @
b8eba847
...
@@ -30,6 +30,37 @@ Docker images are published to [Docker Hub][docker-hub]:
...
@@ -30,6 +30,37 @@ Docker images are published to [Docker Hub][docker-hub]:
$ docker run -P mccutchen/go-httpbin
$ docker run -P mccutchen/go-httpbin
```
```
The
`github.com/mccutchen/go-httpbin/httpbin`
package can also be used as a
library for testing an applications interactions with an upstream HTTP service,
like so:
```
go
package
httpbin_test
import
(
"net/http"
"net/http/httptest"
"testing"
"time"
"github.com/mccutchen/go-httpbin/httpbin"
)
func
TestSlowResponse
(
t
*
testing
.
T
)
{
handler
:=
httpbin
.
NewHTTPBin
()
.
Handler
()
srv
:=
httptest
.
NewServer
(
handler
)
defer
srv
.
Close
()
client
:=
http
.
Client
{
Timeout
:
time
.
Duration
(
1
*
time
.
Second
),
}
_
,
err
:=
client
.
Get
(
srv
.
URL
+
"/delay/10"
)
if
err
==
nil
{
t
.
Fatal
(
"expected timeout error"
)
}
}
```
## Installation
## Installation
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment