diff --git a/README.md b/README.md index 5200184..28d5fbe 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/cmd/root.go b/cmd/root.go index 91e7234..01b8f36 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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)", }, diff --git a/lib/cli.go b/lib/cli.go index 0b27696..51f74f4 100644 --- a/lib/cli.go +++ b/lib/cli.go @@ -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: diff --git a/lib/config.go b/lib/config.go index ee7bcd2..25cd1b8 100644 --- a/lib/config.go +++ b/lib/config.go @@ -28,7 +28,7 @@ type Config struct { firstRequest bool } -var addressReplacer = strings.NewReplacer( +var hostReplacer = strings.NewReplacer( "http://", "", "https://", "", ) @@ -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 }