Get basic UI plumbing in place

This commit is contained in:
Anders Pitman 2020-09-29 22:29:30 -06:00
parent bae4eaf02d
commit bcd786e5d8
3 changed files with 65 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import (
"log" "log"
"net" "net"
"net/http" "net/http"
"html/template"
"strconv" "strconv"
"sync" "sync"
"github.com/caddyserver/certmagic" "github.com/caddyserver/certmagic"
@ -136,7 +137,18 @@ func (p *BoringProxy) handleAdminRequest(w http.ResponseWriter, r *http.Request)
return return
} }
io.WriteString(w, indexTemplate) tmpl, err := template.New("test").Parse(indexTemplate)
if err != nil {
w.WriteHeader(500)
log.Println(err)
io.WriteString(w, "Error compiling index.tmpl")
return
}
tmpl.Execute(w, p.tunMan.tunnels)
//io.WriteString(w, indexTemplate)
case "/tunnels": case "/tunnels":

32
webui/index.tmpl Normal file
View File

@ -0,0 +1,32 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>boringproxy</title>
<link rel="icon" href="data:image/gif;base64,R0lGODlhEAAQAAAAACwAAAAAAQABAAACASgAOw==">
<style>
body {
font-family: Helvetica;
}
.tunnel-list {
display: flex;
flex-direction: column;
}
</style>
</head>
<body>
<div class='tunnel-list'>
{{range $domain, $tunnel:= .}}
<div class='tunnel'>
{{$domain}} {{$tunnel.Port}}
</div>
{{end}}
</div>
</body>
</html>

20
webui/login.tmpl Normal file
View File

@ -0,0 +1,20 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>boringproxy</title>
<link rel="icon" href="data:image/gif;base64,R0lGODlhEAAQAAAAACwAAAAAAQABAAACASgAOw==">
</head>
<body>
<form action="/login" method="post">
<label for="mail">E-mail:</label>
<input type="email" id="mail" name="email">
<button type="submit">Login</button>
</form>
</body>
</html>