Commit ade3cae 1 parent 98a6564 commit ade3cae Copy full SHA for ade3cae
File tree 5 files changed +17
-10
lines changed
5 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -36,10 +36,6 @@ RELAY_PUBKEY="RelayPublicKey"
36
36
# The path can be relative to the binary, or absolute
37
37
DB_PATH=" db/"
38
38
39
- # Where we should store the index.html and static files
40
- # The path can be relative to the binary, or absolute
41
- WEB_PATH=" web/"
42
-
43
39
# Interval in hours to refresh the web of trust
44
40
REFRESH_INTERVAL_HOURS=24
45
41
Original file line number Diff line number Diff line change @@ -2,9 +2,11 @@ package main
2
2
3
3
import (
4
4
"context"
5
+ "embed"
5
6
"fmt"
6
7
"html/template"
7
8
"io"
9
+ "io/fs"
8
10
"log"
9
11
"net/http"
10
12
"os"
@@ -20,6 +22,12 @@ import (
20
22
"github.com/nbd-wtf/go-nostr/nip10"
21
23
)
22
24
25
+ //go:embed template/index.html
26
+ var indexHTML string
27
+
28
+ //go:embed template/assets
29
+ var assets embed.FS
30
+
23
31
var (
24
32
version string
25
33
)
@@ -150,13 +158,16 @@ func main() {
150
158
wg .Wait ()
151
159
152
160
mux := relay .Router ()
153
- web := http .FileServer (http .Dir (config .WebPath ))
154
161
155
- mux .Handle ("GET /web/" , http .StripPrefix ("/web/" , web ))
156
- mux .Handle ("GET /favicon.ico" , http .StripPrefix ("/" , web ))
162
+ serverRoot , fsErr := fs .Sub (assets , "template/assets" )
163
+ if fsErr != nil {
164
+ log .Fatal (fsErr )
165
+ }
166
+ mux .Handle ("/assets/" , http .StripPrefix ("/assets/" , http .FileServer (http .FS (serverRoot ))))
167
+ mux .Handle ("/favicon.ico" , http .FileServer (http .FS (serverRoot )))
157
168
158
169
mux .HandleFunc ("/" , func (w http.ResponseWriter , r * http.Request ) {
159
- tmpl := template .Must (template .ParseFiles ( config . WebPath + "index.html" ))
170
+ tmpl := template .Must (template .New ( "index" ). Parse ( indexHTML ))
160
171
data := struct {
161
172
RelayName string
162
173
RelayPubkey string
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 3
3
< head >
4
4
< meta name ="theme-color " content ="#000000 " />
5
5
< meta charset ="UTF-8 " />
6
- < link rel ="icon " href ="/web /favicon.ico " type ="image/x-icon " />
6
+ < link rel ="icon " href ="/assets /favicon.ico " type ="image/x-icon " />
7
7
< meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
8
8
< title > {{.RelayName}}</ title >
9
9
< script src ="https://cdn.tailwindcss.com "> </ script >
12
12
< div class ="flex-grow flex flex-col justify-center items-center px-4 ">
13
13
<!-- Container -->
14
14
< div class ="flex flex-col text-center max-w-2xl ">
15
- < img src ="/web /icon.png " class ="self-center w-32 " />
15
+ < img src ="/assets /icon.png " class ="self-center w-32 " />
16
16
17
17
< h1 class ="text-5xl md:text-6xl font-bold text-rose-500 mb-6 ">
18
18
{{.RelayName}}
You can’t perform that action at this time.
0 commit comments