Skip to content

Commit

Permalink
Adapt the changelog and REAMDME to new version v0.3.3.Fixes #16
Browse files Browse the repository at this point in the history
  • Loading branch information
aperezg committed May 11, 2019
1 parent 9de929e commit 5e7db4a
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 10 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## v0.3.3 (2019/05/11)

* Improve default CORS options
* Allow up mock server via config file
* Allow configure CORS options
* Access-Control-Request-Method
* Access-Control-Request-Headers
* Access-Control-Allow-Origin
* Access-Control-Expose-Headers
* Access-Control-Allow-Credentials
* Improve route_mateches unit tests

## v0.3.2 (2019/05/08)

* Fix CORS add AccessControl allowing methods and headers
Expand Down Expand Up @@ -37,4 +49,4 @@
* Convert headers into canonical mime type
* Run server with imposter configuration
* Processing and parsing imposters file
* Initial version
* Initial version
71 changes: 64 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ Or you can download the binary for your arch on:

[https://github.com/friendsofgo/killgrave/releases](https://github.com/friendsofgo/killgrave/releases)

### Docker

The application is also available through [Docker](https://hub.docker.com/r/friendsofgo/killgrave), just run:

```bash
docker run -it --rm -p 3000:3000 -v $PWD/:/home -w /home friendsofgo/killgrave
```
Remember to use the [-p](https://docs.docker.com/engine/reference/run/) flag to expose the container port where the application is listening (3000 by default).

NOTE: If you want to use `killgrave` through Docker at the same time you use your own dockerised HTTP-based API, be careful with networking issues.

## Using Killgrave

Use `killgrave` with default flags:
Expand All @@ -39,6 +50,8 @@ $ killgrave
```
Or custome your server with this flags:
```sh
-config string
path with configuration file
-host string
if you run your server on a different host (default "localhost")
-imposters string
Expand All @@ -49,6 +62,28 @@ Or custome your server with this flags:
show the version of the application
```
Use `killgrave` with config file:
First of all you need create a file with a valid config, i.e:
```yaml
#config.yml

imposters_path: "imposters"
port: 3000
host: "localhost"
cors:
methods: ["GET"]
headers: ["Content-Type"]
exposed_headers: ["Cache-Control"]
origins: ["*"]
allow_credentials: true
```
The parameter `cors` is optional and his options can be empty array, the other options `imposters_path`, `port`, `host` are mandatory.
If you want more information about the CORS options, visit the [CORS section](#CORS).
## How to use
### Create an imposter
Expand Down Expand Up @@ -178,17 +213,37 @@ curl --header "Content-Type: application/json" \
http://localhost:3000/gophers
```
### Docker
## CORS
The application is also available through [Docker](https://hub.docker.com/r/friendsofgo/killgrave), just run:
If you want to use `killgrave` on your client application you must consider to configure correctly all about CORS, thus we offer the possibility to configure as you need through a config file.
```bash
docker run -it --rm -p 3000:3000 friendsofgo/killgrave
```
In the CORS section of the file you can found the next options:
Remember to use the [-p](https://docs.docker.com/engine/reference/run/) flag to expose the container port where the application is listening (3000 by default).
- **methods** (string array)
Represent the **Access-Control-Request-Method header**, if you not specified or leave as empty array the default value will be:
NOTE: If you want to use `killgrave` through Docker at the same time you use your own dockerised HTTP-based API, be careful with networking issues.
`"GET", "HEAD", "POST", "PUT", "OPTIONS", "DELETE", "PATCH", "TRACE", "CONNECT"`
- **headers** (string array)
Represent the **Access-Control-Request-Headers header**, if you not specified or leave as empty array the default value will be:
`"X-Requested-With", "Content-Type", "Authorization"`
- **exposed_headers** (string array)
Represent the **Access-Control-Expose-Headers header**, if you not specified or leave as empty array the default value will be:
`"Cache-Control", "Content-Language", "Content-Type", "Expires", "Last-Modified", "Pragma"`
- **origins** (string array)
Represent the **Access-Control-Allow-Origin header**, if you not specified or leave as empty array this options has not default value
- **allow_credentials** (boolean)
Represent the **Access-Control-Allow-Credentials header** you must indicate if true or false
## Features
* Imposters created in json
Expand All @@ -206,6 +261,8 @@ NOTE: If you want to use `killgrave` through Docker at the same time you use you
* Dynamic responses based on query params
* Allow organize your imposters with structured folders
* Allow write multiple imposters by file
* Run mock server with predefined configuration with config yaml file
* Configure your CORS server options
## Next Features
- [ ] Proxy server
Expand Down
2 changes: 0 additions & 2 deletions internal/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package killgrave

import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
Expand Down Expand Up @@ -55,7 +54,6 @@ func (s *Server) AccessControl(config ConfigCORS) (h []handlers.CORSOption) {
h = append(h, handlers.ExposedHeaders(config.ExposedHeaders))
}

fmt.Println(config)
if config.AllowCredentials {
h = append(h, handlers.AllowCredentials())
}
Expand Down

0 comments on commit 5e7db4a

Please sign in to comment.