From 169a7d232f617726542a0626850c4e097203b86f Mon Sep 17 00:00:00 2001 From: sp Date: Thu, 25 Feb 2021 00:05:01 +1100 Subject: [PATCH] static file server installed for docRoot --- go.sum | 13 +++++++++++++ html/css/index.css | 3 +++ html/index.html | 9 +++++++++ main.go | 4 +++- 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 go.sum create mode 100644 html/css/index.css create mode 100644 html/index.html diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..cba2ba3 --- /dev/null +++ b/go.sum @@ -0,0 +1,13 @@ +github.com/VividCortex/mysqlerr v0.0.0-20201215173831-4c396ae82aac h1:4w4jPA8uNKNtkEcVmMwcjXwkLbCnPpx//7RPWQHGPUA= +github.com/VividCortex/mysqlerr v0.0.0-20201215173831-4c396ae82aac/go.mod h1:f3HiCrHjHBdcm6E83vGaXh1KomZMA2P6aeo3hKx/wg0= +github.com/brianvoe/gofakeit/v6 v6.0.1 h1:U8cuIYQQaIQBEloSbTk1hs5v5aDkoZHVq/pljqNA9qM= +github.com/brianvoe/gofakeit/v6 v6.0.1/go.mod h1:palrJUk4Fyw38zIFB/uBZqsgzW5VsNllhHKKwAebzew= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/html/css/index.css b/html/css/index.css new file mode 100644 index 0000000..0c2b980 --- /dev/null +++ b/html/css/index.css @@ -0,0 +1,3 @@ +H1 { + background-color:yellow; +} \ No newline at end of file diff --git a/html/index.html b/html/index.html new file mode 100644 index 0000000..faec340 --- /dev/null +++ b/html/index.html @@ -0,0 +1,9 @@ + + Demo static index + + + +

this is static file

+ test link index.css + + diff --git a/main.go b/main.go index c1dcb8e..6b09ec3 100644 --- a/main.go +++ b/main.go @@ -24,6 +24,9 @@ func main() { func setupRootFileServer() { + fs := http.FileServer(http.Dir(config.DocRoot)) + http.Handle("/", http.StripPrefix("/", fs)) + } func setupHTTPHandler() { @@ -41,7 +44,6 @@ func setupHTTPHandler() { http.HandleFunc("/spa/livecast", HelloHandler) http.HandleFunc("/spa/editmeeting", HelloHandler) - http.HandleFunc("/", HelloHandler) fmt.Printf("Server started at port %s\n", config.Port) log.Fatal(http.ListenAndServe(config.Host+":"+config.Port, nil))