capture/config.go

29 lines
798 B
Go
Raw Normal View History

2017-11-08 00:10:54 +01:00
package main
2018-09-16 16:18:39 +02:00
import (
"flag"
)
2017-11-08 00:10:54 +01:00
2021-04-06 12:19:16 +02:00
// Config has all the configuration parsed from the command line.
2018-09-16 16:21:36 +02:00
type Config struct {
2019-11-09 00:27:02 +01:00
TargetURL string
ProxyPort string
DashboardPort string
MaxCaptures int
2018-07-21 19:50:53 +02:00
}
2021-04-06 12:19:16 +02:00
// ReadConfig reads the arguments from the command line.
2018-09-16 16:21:36 +02:00
func ReadConfig() Config {
2019-12-24 10:42:44 +01:00
targetURL := flag.String("url", "https://jsonplaceholder.typicode.com", "Required. Set the url you want to proxy")
proxyPort := flag.String("port", "9000", "Set the proxy port")
2019-11-09 00:27:02 +01:00
dashboardPort := flag.String("dashboard", "9001", "Set the dashboard port")
2019-11-09 00:49:29 +01:00
maxCaptures := flag.Int("captures", 16, "Set how many captures to show in the dashboard")
2017-11-08 00:10:54 +01:00
flag.Parse()
2018-09-16 16:21:36 +02:00
return Config{
2019-11-09 00:27:02 +01:00
TargetURL: *targetURL,
ProxyPort: *proxyPort,
MaxCaptures: *maxCaptures,
DashboardPort: *dashboardPort,
2018-09-16 16:18:39 +02:00
}
2017-11-08 00:10:54 +01:00
}