Skip to content

Commit

Permalink
rename option delay to add-delay
Browse files Browse the repository at this point in the history
  • Loading branch information
janiltonmaciel committed Aug 27, 2020
1 parent 9a567eb commit 8c65d9b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,28 @@ OPTIONS:
## Examples
- start server at http://0.0.0.0:9000 serving "." current directory
```bash
```bash
statiks -port 9000
```
```
- start server at http://0.0.0.0:9080 serving "/home" with CORS
```bash
```bash
statiks --cors /home
```
```
- start server at http://192.168.1.100:9080 serving "/tmp" with gzip compression
```bash
```bash
statiks --host 192.168.1.100 --compression /tmp
```
```
- start server at https://0.0.0.0:9080 serving "." with HTTPS
```bash
```bash
statiks --ssl --cert cert.pem --key key.pem
```
- start server at http://0.0.0.0:9000 serving "/tmp" with delay response 100ms
```bash
statiks -add-delay 100 /tmp
```
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func createFlags() []cli.Flag {
Usage: "enable quiet mode, don't output each incoming request",
},
&cli.Int64Flag{
Name: "delay",
Name: "add-delay",
Value: 0,
Usage: "add delay to responses (in milliseconds)",
},
Expand Down
3 changes: 3 additions & 0 deletions lib/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ EXAMPLES:
- start server at https://0.0.0.0:9080 serving "." with HTTPS
statiks --ssl --cert cert.pem --key key.pem
- start server at http://0.0.0.0:9000 serving "/tmp" with delay response 100ms
statiks -add-delay 100 /tmp
{{- if .Version }}
VERSION:
Expand Down
8 changes: 4 additions & 4 deletions lib/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type Config struct {
firstRequest bool
}

var addressReplacer = strings.NewReplacer(
var hostReplacer = strings.NewReplacer(
"http://", "",
"https://", "",
)
Expand Down Expand Up @@ -67,11 +67,11 @@ func getPath(c *cli.Context) (path string) {
}

func getHostAddress(c *cli.Context) string {
address := c.String("address")
return addressReplacer.Replace(address)
host := c.String("host")
return hostReplacer.Replace(host)
}

func getDelay(c *cli.Context) time.Duration {
delay := c.Int64("delay")
delay := c.Int64("add-delay")
return time.Duration(delay) * time.Millisecond
}

0 comments on commit 8c65d9b

Please sign in to comment.