Embedded assets

This commit is contained in:
Justin Hawkins 2017-07-27 22:04:32 +09:30
parent f976777f40
commit e240f5dbd0
2 changed files with 10 additions and 1 deletions

1
data/index.html Normal file
View File

@ -0,0 +1 @@
THIS IS SPARTA

View File

@ -1,6 +1,7 @@
package web package web
import ( import (
"discord-auto-upload/asset"
"encoding/json" "encoding/json"
"fmt" "fmt"
"log" "log"
@ -30,7 +31,13 @@ var wsConfig DAUWebServer
// } // }
func getIndex(w http.ResponseWriter, r *http.Request) { func getIndex(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "index here") data, err := asset.Asset("index.html")
if err != nil {
// Asset was not found.
fmt.Fprintln(w, err)
}
w.Write(data)
} }
func getSetWebhook(w http.ResponseWriter, r *http.Request) { func getSetWebhook(w http.ResponseWriter, r *http.Request) {
@ -67,4 +74,5 @@ func startWebServer() {
if err != nil { if err != nil {
log.Fatal("ListenAndServe: ", err) log.Fatal("ListenAndServe: ", err)
} }
} }