Exemple #1
0
func main() {
	fmt.Println("ENVAPP", env.Addr())

	router := mux.NewRouter()

	router.HandleFunc("/app", appHandler)
	router.HandleFunc("/service/{name}", svcHandler)

	http.Handle("/", router)

	log.Fatal(http.ListenAndServe(env.Addr(), nil))
}
Exemple #2
0
	. "github.com/onsi/gomega"

	"github.com/st3v/cfkit/env"
)

var _ = Describe(".Addr", func() {
	Context("when env var PORT is set", func() {
		BeforeEach(func() {
			os.Setenv("PORT", "1234")
		})

		AfterEach(func() {
			os.Unsetenv("PORT")
		})

		It("returns the expected address", func() {
			Expect(env.Addr()).To(Equal(":1234"))
		})
	})

	Context("when env var PORT is not set", func() {
		BeforeEach(func() {
			os.Unsetenv("PORT")
		})

		It("returns the expected address", func() {
			Expect(env.Addr()).To(Equal(":"))
		})
	})
})