asset_nodev.gen.go 764 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // AUTOMATICALLY GENERATED FILE. DO NOT EDIT.
  2. // +build !dev
  3. package main
  4. import (
  5. "encoding/base64"
  6. "hash/fnv"
  7. "io"
  8. "net/http"
  9. "strings"
  10. "time"
  11. )
  12. type asset struct {
  13. Name string
  14. Content string
  15. etag string
  16. }
  17. func (a asset) init() asset {
  18. // This is a method to minize the namespace pollution. Use
  19. // chaining to make it callable in variable declarations.
  20. h := fnv.New64a()
  21. _, _ = io.WriteString(h, a.Content)
  22. a.etag = `"` + base64.StdEncoding.EncodeToString(h.Sum(nil)) + `"`
  23. return a
  24. }
  25. func (a asset) ServeHTTP(w http.ResponseWriter, req *http.Request) {
  26. if a.etag != "" && w.Header().Get("ETag") == "" {
  27. w.Header().Set("ETag", a.etag)
  28. }
  29. body := strings.NewReader(a.Content)
  30. http.ServeContent(w, req, a.Name, time.Time{}, body)
  31. }