asset_dev.gen.go 983 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // AUTOMATICALLY GENERATED FILE. DO NOT EDIT.
  2. // +build dev
  3. package main
  4. import (
  5. "go/build"
  6. "net/http"
  7. "os"
  8. "path/filepath"
  9. "time"
  10. )
  11. type asset struct {
  12. Name string
  13. Content string
  14. // don't bother precomputing ETag if we're reloading from disk
  15. }
  16. func (a asset) init() asset {
  17. return a
  18. }
  19. func (a asset) importPath() string {
  20. // filled at code gen time
  21. return "github.com/cryptix/exp/reacTest/p1"
  22. }
  23. func (a asset) Open() (*os.File, error) {
  24. path := a.importPath()
  25. pkg, err := build.Import(path, ".", build.FindOnly)
  26. if err != nil {
  27. return nil, err
  28. }
  29. p := filepath.Join(pkg.Dir, a.Name)
  30. return os.Open(p)
  31. }
  32. func (a asset) ServeHTTP(w http.ResponseWriter, req *http.Request) {
  33. body, err := a.Open()
  34. if err != nil {
  35. // show the os.Open message, with paths and all, but this only
  36. // happens in dev mode.
  37. http.Error(w, err.Error(), http.StatusInternalServerError)
  38. return
  39. }
  40. defer body.Close()
  41. http.ServeContent(w, req, a.Name, time.Time{}, body)
  42. }