mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
# 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
32 lines
730 B
Go
32 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
|
|
}
|