@@ -22,23 +22,6 @@ var indexHTML string
2222//go:embed sixlines.html
2323var sixlinesHTML string
2424
25- // indexBefore and indexAfter are the two halves of index.html split at the
26- // access counter insertion point. Populated by init().
27- var indexBefore , indexAfter string
28-
29- const accessMarker = "{{ACCESS}}"
30-
31- func init () {
32- for i := 0 ; i <= len (indexHTML )- len (accessMarker ); i ++ {
33- if indexHTML [i :i + len (accessMarker )] == accessMarker {
34- indexBefore = indexHTML [:i ]
35- indexAfter = indexHTML [i + len (accessMarker ):]
36- return
37- }
38- }
39- indexBefore = indexHTML
40- }
41-
4225var (
4326 ssid string
4427 password string
@@ -49,10 +32,7 @@ func main() {
4932 // wait a bit for serial
5033 time .Sleep (2 * time .Second )
5134
52- link := link.Esplink {
53- // link needs a 48k arena pool to handle the blob allocations for WiFi.
54- ArenaPoolSize : 48 * 1024 ,
55- }
35+ link := link.Esplink {}
5636 netdev .UseNetdev (& link )
5737
5838 println ("Connecting to WiFi..." )
@@ -88,37 +68,12 @@ func logRequest(h http.HandlerFunc) http.Handler {
8868}
8969
9070func root (w http.ResponseWriter , r * http.Request ) {
91- access := 1
92-
93- cookie , err := r .Cookie ("access" )
94- if err != nil {
95- if err == http .ErrNoCookie {
96- cookie = & http.Cookie {
97- Name : "access" ,
98- Value : "1" ,
99- }
100- } else {
101- http .Error (w , err .Error (), http .StatusBadRequest )
102- return
103- }
104- } else {
105- v , err := strconv .ParseInt (cookie .Value , 10 , 0 )
106- if err != nil {
107- http .Error (w , "invalid cookie.Value : " + cookie .Value , http .StatusBadRequest )
108- return
109- }
110- cookie .Value = strconv .Itoa (int (v ) + 1 )
111- access = int (v ) + 1
112- }
113- http .SetCookie (w , cookie )
11471 w .WriteHeader (http .StatusOK )
115-
116- io .WriteString (w , indexBefore )
117- io .WriteString (w , strconv .Itoa (access ))
118- io .WriteString (w , indexAfter )
72+ io .WriteString (w , indexHTML )
11973}
12074
12175func sixlines (w http.ResponseWriter , r * http.Request ) {
76+ w .WriteHeader (http .StatusOK )
12277 io .WriteString (w , sixlinesHTML )
12378}
12479
0 commit comments