~mendelmaleh/bin

453dd0d1c1e1ce0a919e4bcb41548d9814c824a0 — Mendel E 1 year, 2 months ago f4af5d1 v2
Embed index.html
1 files changed, 8 insertions(+), 4 deletions(-)

M main.go
M main.go => main.go +8 -4
@@ 1,6 1,7 @@
package main

import (
	_ "embed"
	"errors"
	"fmt"
	"io"


@@ 23,6 24,9 @@ type Config struct {
	Words WordsConfig
}

//go:embed index.html
var index []byte

func main() {
	var config Config
	var words *Words


@@ 60,11 64,11 @@ func main() {
		resp := func() string {
			if r.Method == http.MethodGet {
				if r.URL.Path == "/" {
					// TODO: include file
					http.ServeFile(w, r, "index.html")
					w.Write(index)
				} else {
					// serve pastebin from bins dir
					http.ServeFile(w, r, config.Bin.Dir+r.URL.Path)
				}
				// serve pastebin from bins dir
				http.ServeFile(w, r, config.Bin.Dir+r.URL.Path)
			}

			if r.Method == http.MethodPost {