Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@random-robbie
Created December 11, 2018 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save random-robbie/6fc19f6018ea4f15f8844b7dfe85c32e to your computer and use it in GitHub Desktop.
Save random-robbie/6fc19f6018ea4f15f8844b7dfe85c32e to your computer and use it in GitHub Desktop.
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "API Brdige for Proclaim")
})
http.HandleFunc("/test/workflow", tworkflows)
http.HandleFunc("/test/status", tstatus)
http.HandleFunc("/test/engineer", tengineer)
http.HandleFunc("/test/bookengineer", tbengineer)
http.HandleFunc("/test/task", ttask)
http.HandleFunc("/test/taskdetails", ttaskdetails)
http.HandleFunc("/test/sendfile", tsendfile)
http.HandleFunc("/test/getfile", tgetfile)
http.HandleFunc("/test/getfiles", tgetfiles)
http.HandleFunc("/live/workflow", lworkflows)
http.HandleFunc("/live/status", lstatus)
http.HandleFunc("/live/engineer", lengineer)
http.HandleFunc("/live/bookengineer", lbengineer)
http.HandleFunc("/live/task", ltask)
http.HandleFunc("/live/taskdetails", ltaskdetails)
http.HandleFunc("/live/sendfile", lsendfile)
http.HandleFunc("/live/getfile", lgetfile)
http.HandleFunc("/live/getfiles", lgetfiles)
flag.Parse()
fport := ":"+*port+""
fmt.Printf("Started API Bridge Server on port "+*port+"...\n")
fmt.Printf("Press CTRL + C to terminate\n")
var gracefulStop = make(chan os.Signal)
signal.Notify(gracefulStop, syscall.SIGTERM)
signal.Notify(gracefulStop, syscall.SIGINT)
go func() {
sig := <-gracefulStop
fmt.Printf("caught sig: %+v", sig)
fmt.Println("Wait for 2 second to finish processing")
time.Sleep(2*time.Second)
os.Exit(0)
}()
err := http.ListenAndServe(fport, nil) // setting listening port
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment