func main() { certPath := flag.String("cert", "", "path to DER encoded certificate for SSL, - for stdin") keyPath := flag.String("key", "", "path to DER encoded private key for SSL, - for stdin") flag.Parse() if len(flag.Args()) != 2 { fmt.Fprintf(os.Stderr, "Usage: %s [flags] domain service-name\n", os.Args[0]) flag.PrintDefaults() os.Exit(64) } domain, serviceName := flag.Arg(0), flag.Arg(1) var stdin []byte var err error if *certPath == "-" || *keyPath == "-" { stdin, err = ioutil.ReadAll(os.Stdin) if err != nil { log.Fatal("Failed to read from stdin: ", err) } } tlsCert, err := readCert(*certPath, stdin) if err != nil { return } tlsKey, err := readKey(*keyPath, stdin) if err != nil { return } client, err := client.New() if err != nil { log.Fatal(err) } conf := &strowger.HTTPRoute{ Service: serviceName, Domain: domain, TLSCert: string(tlsCert), TLSKey: string(tlsKey), } if err := client.CreateRoute(conf.ToRoute()); err != nil { log.Fatal(err) } }
func main() { var err error scheduler, err = sampic.New() if err != nil { log.Fatal(err) } disc, err = discover.NewClient() if err != nil { log.Fatal(err) } router, err = strowgerc.New() if err != nil { log.Fatal(err) } mux := tigertonic.NewTrieServeMux() mux.Handle("PUT", "/apps/{app_id}/domains/{domain}", tigertonic.Marshaled(addDomain)) mux.Handle("POST", "/apps/{app_id}/formation/{formation_id}", tigertonic.Marshaled(changeFormation)) mux.Handle("GET", "/apps/{app_id}/jobs", tigertonic.Marshaled(getJobs)) mux.HandleFunc("GET", "/apps/{app_id}/jobs/{job_id}/logs", getJobLog) mux.HandleFunc("POST", "/apps/{app_id}/jobs", runJob) http.ListenAndServe("127.0.0.1:1200", tigertonic.Logged(mux, nil)) }