github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/integration/assets/go_calls_ruby/site.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"log"
     6  	"net/http"
     7  	"os"
     8  	"os/exec"
     9  )
    10  
    11  func main() {
    12  	http.HandleFunc("/", hello)
    13  	fmt.Println("listening...")
    14  	err := http.ListenAndServe(":"+os.Getenv("PORT"), nil)
    15  	if err != nil {
    16  		panic(err)
    17  	}
    18  }
    19  
    20  func hello(res http.ResponseWriter, req *http.Request) {
    21  	bundlerVersion, err := exec.Command("bundle", "--version").Output()
    22  	if err != nil {
    23  		res.WriteHeader(http.StatusInternalServerError)
    24  		log.Print("ERROR:", err)
    25  		fmt.Fprintf(res, "ERROR: %v\n", err)
    26  	} else {
    27  		fmt.Fprintf(res, "The bundler version is: %s\n", bundlerVersion)
    28  	}
    29  }