forked from Unee-T-INS/invite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
asset_dev.gen.go
50 lines (42 loc) · 904 Bytes
/
asset_dev.gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// AUTOMATICALLY GENERATED FILE. DO NOT EDIT.
// +build dev
package invite
import (
"go/build"
"net/http"
"os"
"path/filepath"
"time"
)
type asset struct {
Name string
Content string
etag string
}
func (a asset) init() asset {
return a
}
func (a asset) importPath() string {
// filled at code gen time
return "."
}
func (a asset) Open() (*os.File, error) {
path := a.importPath()
pkg, err := build.Import(path, ".", build.FindOnly)
if err != nil {
return nil, err
}
p := filepath.Join(pkg.Dir, a.Name)
return os.Open(p)
}
func (a asset) ServeHTTP(w http.ResponseWriter, req *http.Request) {
body, err := a.Open()
if err != nil {
// show the os.Open message, with paths and all, but this only
// happens in dev mode.
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
defer body.Close()
http.ServeContent(w, req, a.Name, time.Time{}, body)
}