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

templatebundle.go 584B

12345678910111213141516171819202122232425
  1. package handlers
  2. import (
  3. "bytes"
  4. "encoding/gob"
  5. "log"
  6. "net/http"
  7. "github.com/isomorphicgo/isogoapp/common"
  8. )
  9. func TemplateBundleHandler(env *common.Env) http.Handler {
  10. return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  11. var templateContentItemsBuffer bytes.Buffer
  12. enc := gob.NewEncoder(&templateContentItemsBuffer)
  13. m := env.TemplateSet.Bundle().Items()
  14. err := enc.Encode(&m)
  15. if err != nil {
  16. log.Print("encoding err: ", err)
  17. }
  18. w.Header().Set("Content-Type", "application/octet-stream")
  19. w.Write(templateContentItemsBuffer.Bytes())
  20. })
  21. }