27
"github.com/gorilla/mux"
32
func NewHandler() *handler {
36
func (h *handler) get(w http.ResponseWriter, r *http.Request) {
39
if err == ErrNotFound {
40
w.WriteHeader(http.StatusNotFound)
41
fmt.Fprint(w, "No OEM package installed")
42
} else if err == ErrTooMany {
43
w.WriteHeader(http.StatusInternalServerError)
44
fmt.Fprint(w, fmt.Sprintf("Error: %s", err))
45
} else if err == ErrDecode {
46
w.WriteHeader(http.StatusInternalServerError)
47
fmt.Fprint(w, fmt.Sprintf("Error: %s", err))
51
enc := json.NewEncoder(w)
52
if err := enc.Encode(data); err != nil {
53
w.WriteHeader(http.StatusInternalServerError)
54
fmt.Fprint(w, fmt.Sprintf("Error: %s", err))
59
func (h *handler) MakeMuxer(prefix string) http.Handler {
65
m = mux.NewRouter().PathPrefix(prefix).Subrouter()
69
m.HandleFunc("/", h.get).Methods("GET")
74
25
func glob(dir string, filename string) (pkgs []string, err error) {
75
26
err = filepath.Walk(dir, func(path string, f os.FileInfo, err error) error {
76
27
if filepath.Base(path) == filename {