github.com/loafoe/cli@v7.1.0+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  }