A basic, barebones web app, intented to be used as a starting point for developing an Isomorphic Go application.

isogoapp.go 718B

123456789101112131415161718192021222324252627282930
  1. package main
  2. import (
  3. "fmt"
  4. "net/http"
  5. "os"
  6. "github.com/gorilla/mux"
  7. "github.com/isomorphicgo/isogoapp/handlers"
  8. )
  9. var WebAppRoot string = os.Getenv("ISOGO_APP_ROOT")
  10. func main() {
  11. if WebAppRoot == "" {
  12. fmt.Println("The ISOGO_APP_ROOT environment variable must be set before the web server instance can be started.")
  13. os.Exit(1)
  14. }
  15. fs := http.FileServer(http.Dir(WebAppRoot + "/static"))
  16. r := mux.NewRouter()
  17. r.HandleFunc("/", handlers.IndexHandler)
  18. r.HandleFunc("/js/client.js", handlers.GopherjsScriptHandler)
  19. r.HandleFunc("/js/client.js.map", handlers.GopherjsScriptMapHandler)
  20. http.Handle("/", r)
  21. http.Handle("/static/", http.StripPrefix("/static", fs))
  22. http.ListenAndServe(":8080", nil)
  23. }