mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
42b3e5602e
# Checklist for submitter If some of the following don't apply, delete the relevant line. - [x] Changes file added for user-visible changes in `changes/` or `orbit/changes/`. See [Changes files](https://fleetdm.com/docs/contributing/committing-changes#changes-files) for more information. - [x] Added/updated tests - [x] Manual QA for all new/changed functionality
33 lines
730 B
Go
33 lines
730 B
Go
// This server can be used to serve the chrome extension during local
|
|
// development (though it is usually easier to use the "load unpacked" option in
|
|
// Chrome).
|
|
|
|
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
"regexp"
|
|
)
|
|
|
|
// The directory to serve.
|
|
var (
|
|
d = http.Dir(".")
|
|
fileserver = http.FileServer(d)
|
|
tFile = regexp.MustCompile(`\.crx$`)
|
|
)
|
|
|
|
func myfileserver(w http.ResponseWriter, r *http.Request) {
|
|
ruri := r.RequestURI
|
|
log.Println("request for: ", ruri)
|
|
if tFile.MatchString(ruri) {
|
|
w.Header().Set("Content-Type", "application/x-chrome-extension")
|
|
}
|
|
fileserver.ServeHTTP(w, r)
|
|
}
|
|
|
|
func main() {
|
|
http.HandleFunc("/", myfileserver)
|
|
log.Fatal(http.ListenAndServe("localhost:1337", nil)) //nolint:gosec
|
|
}
|