Skip to content

Commit

Permalink
Merge pull request #84 from stripe/brandur-https-options
Browse files Browse the repository at this point in the history
Support simultaneous HTTP and HTTPS
  • Loading branch information
brandur-stripe authored Jul 19, 2018
2 parents 3615845 + f71d810 commit 858c61c
Show file tree
Hide file tree
Showing 4 changed files with 428 additions and 76 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /
COPY --from=builder /go/src/github.com/stripe/stripe-mock/stripe-mock .
ENTRYPOINT /stripe-mock
ENTRYPOINT ["/stripe-mock", "-http-port", "12111", "-https-port", "12112"]
EXPOSE 12111
EXPOSE 12112
70 changes: 54 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,85 @@ the API reference][apiref].

## Usage

Get it from Homebrew or download it [from the releases page][releases]:
If you have Go installed, you can install the basic binary with:

``` sh
brew install stripe/stripe-mock/stripe-mock
go get -u github.com/stripe/stripe-mock
```

# start a stripe-mock service at login
brew services start stripe-mock
With no arguments, stripe-mock will listen with HTTP on its default port of
`12111`:

# upgrade if you already have it
brew upgrade stripe-mock
``` sh
stripe-mock
```

Or if you have Go installed you can build it:
It can also be activated with HTTPS (and by extension support for HTTP/2) using
the `-https` flag (the default port changes to `12112` for HTTPS):

``` sh
go get -u github.com/stripe/stripe-mock
stripe-mock -https
```

Run it:
For either HTTP or HTTPS, the port can be specified with either the `PORT`
environmental variable or the `-port` option (the latter is preferred if both
are present):

``` sh
stripe-mock
stripe-mock -port 12111
```

It can also listen on a Unix socket:

``` sh
stripe-mock -https -unix /tmp/stripe-mock-secure.sock
```

It can be configured to receive both HTTP _and_ HTTPS by using the
`-http-port`, `-http-unix`, `-https-port`, and `-https-unix` options (and note
that these cannot be mixed with any of the basic options above):

``` sh
stripe-mock -http-port 12111 -https-port 12112
```

Or with docker:
### Homebrew

Get it from Homebrew or download it [from the releases page][releases]:

``` sh
brew install stripe/stripe-mock/stripe-mock

# start a stripe-mock service at login
brew services start stripe-mock

# upgrade if you already have it
brew upgrade stripe-mock
```

The Homebrew service listens on port `12111` for HTTP and `12112` for HTTPS and
HTTP/2.

### Docker

``` sh
# build
docker build . -t stripe-mock
# run
docker run -p 12111:12111 stripe-mock
docker run -p 12111:12112 stripe-mock
```

Then from another terminal:
The default Docker `ENTRYPOINT` listens on port `12111` for HTTP and `12112`
for HTTPS and HTTP/2.

### Sample request

After you've started stripe-mock, you can try a sample request against it:

``` sh
curl -i http://localhost:12111/v1/charges -H "Authorization: Bearer sk_test_123"
```

By default, stripe-mock runs on port 12111, but is configurable with the
`-port` option.

## Development

### Testing
Expand Down
Loading

0 comments on commit 858c61c

Please sign in to comment.