Skip to content

nathanows/httpbin-go

Repository files navigation

httpbin-go: HTTP Request & Response Service

GitHub Build Status codecov Docker Pulls Go Report Card

httpbin-go is a Go port of the popular requests/httpbin, and its corresponding Docker image kennethreitz/httpbin.

The original httpbin Docker container tips the scales at ~500MB, httpbin-go is >80x smaller (~6MB) and 10x faster (see performance comparison below).

Usage

httpbin-go is an HTTP Request & Response Service, written in Go. Like the original httpbin, httpbin-go is an HTTP server that responds in predictable ways to a specified set of HTTP requests. For many endpoints the service echoes back much of the data given to it so that a developer can see what their HTTP client code is doing.

Docker

docker run -p 8080:8080 nathanows/httpbin-go

Build and Run Locally

go build cmd/httpbin/main.go -o httpbin-go
go run httpbin-go

Hosted Service

curl -v http://httpbin-go.com/get

Sample Use Cases

TODO

Endpoints Implemented

Where possible, endpoint have been implemented to match the original implementation (specified here: https://httpbin.org/).

The following endpoints have not yet been implemented in this project:

  • /digest-auth/{qop}/{user}/{passwd} [GET]
  • /digest-auth/{qop}/{user}/{passwd}/{algorithm} [GET]
  • /digest-auth/{qop}/{user}/{passwd}/{algorithm}/{stale_after} [GET]
  • /brotli [GET]
  • /deflate [GET]
  • /gzip [GET]
  • /absolute-redirect/{n} [GET]
  • /redirect-to/{n} [GET]
  • /relative-redirect/{n} [GET]

Click below to see the current implementation status of all endpoints:

Endpoint Implementation Status

HTTP

  • /delete [DELETE]
  • /get [GET]
  • /patch [PATCH]
  • /post [POST]
  • /put [PUT]

Auth

  • /basic-auth/{user}/{passwd} [GET]
  • /bearer [GET]
  • /digest-auth/{qop}/{user}/{passwd} [GET]
  • /digest-auth/{qop}/{user}/{passwd}/{algorithm} [GET]
  • /digest-auth/{qop}/{user}/{passwd}/{algorithm}/{stale_after} [GET]
  • /hidden-basic-auth/{user}/{passwd} [GET]

Status Codes

  • /status/{codes} [DELETE, GET, PATCH, POST, PUT]

Request Inspection

  • /headers [GET]
  • /ip [GET]
  • /user-agent [GET]

Response Inspection

  • /cache [GET]
  • /cache/{value} [GET]
  • /etag/{etag} [GET]
  • /response-headers [GET, POST]

Response Formats

  • /brotli [GET]
  • /deflate [GET]
  • /deny [GET]
  • /encoding/utf8 [GET]
  • /gzip [GET]
  • /html [GET]
  • /json [GET]
  • /robots.txt [GET]
  • /xml [GET]

Dynamic Data

  • /base64/{value} [GET]
  • /bytes/{n} [GET]
  • /delay/{delay} [DELETE, GET, PATCH, POST, PUT]
  • /drip [GET]
  • /links/{n}/{offset} [GET]
  • /range/{numbytes} [GET]
  • /stream-bytes/{n} [GET]
  • /stream/{n} [GET]
  • /uuid [GET]

Cookies

  • /cookies [GET]
  • /cookies/delete [GET]
  • /cookies/set [GET]
  • /cookies/set/{name}/{value} [GET]

Images

  • /image [GET]
  • /image/jpeg [GET]
  • /image/png [GET]
  • /image/svg [GET]
  • /image/webp [GET]

Redirects

  • /absolute-redirect/{n} [GET]
  • /redirect-to [DELETE, GET, PATCH, POST, PUT]
  • /redirect-to/{n} [GET]
  • /relative-redirect/{n} [GET]

Anything

  • /anything [DELETE, GET, PATCH, POST, PUT]
  • /anything/{anything} [DELETE, GET, PATCH, POST, PUT]

Performance Comparison

TODO

Features

  • Replicate all existing httpbin endpoints
  • Performance benchmarking
  • Host public service at www.httpbin-go.com
  • Add TLS support
  • Add swagger docs

About

httpbin-go: HTTP Request & Response Service

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published