-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfizzbuzz.go
More file actions
42 lines (34 loc) · 1.03 KB
/
fizzbuzz.go
File metadata and controls
42 lines (34 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"flag"
"github.com/domdavis/fizzbuzz/handlers"
"github.com/domdavis/fizzbuzz/microservice"
)
func main() {
var service, url, fizz, buzz, number string
var port int
flag.StringVar(&service, "service", "",
"The service to run [fizz, buzz, number or fizzbuzz] (Required).")
flag.StringVar(&url, "url", "",
"The url to run on (default is the service name")
flag.IntVar(&port, "port", 8000, "The port to run on (default 8000)")
flag.StringVar(&fizz, "fizz", "localhost:8000/fizz",
"The url for the fizz service.")
flag.StringVar(&buzz, "buzz", "localhost:8000/buzz",
"The url for the buzz service.")
flag.StringVar(&number, "number", "localhost:8000/number",
"The url for the number service.")
flag.Parse()
if url == "" {
url = service
}
switch {
case service == "fizzbuzz":
microservice.NewMicroservice(
url, handlers.FizzBuzz(fizz, buzz, number), port)
case handlers.Handlers[service] != nil:
microservice.NewMicroservice(url, handlers.Handlers[service], port)
default:
flag.Usage()
}
}