This commit is contained in:
Your Name 2024-02-19 12:08:07 -05:00
parent baf7e11ebe
commit 673a0c26cd
3 changed files with 21 additions and 5 deletions

1
go.mod
View File

@ -6,6 +6,7 @@ require (
git.teamworkapps.com/shortcut/forms v0.0.0-20240202203738-c42dc9446449 // indirect
github.com/emersion/go-message v0.18.0 // indirect
github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/knadh/go-pop3 v0.3.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
)

2
go.sum
View File

@ -5,6 +5,8 @@ github.com/emersion/go-message v0.18.0 h1:7LxAXHRpSeoO/Wom3ZApVZYG7c3d17yCScYce8
github.com/emersion/go-message v0.18.0/go.mod h1:Zi69ACvzaoV/MBnrxfVBPV3xWEuCmC2nEN39oJF4B8A=
github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594 h1:IbFBtwoTQyw0fIM5xv1HF+Y+3ZijDR839WMulgxCcUY=
github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594/go.mod h1:aqO8z8wPrjkscevZJFVE1wXJrLpC5LtJG7fqLOsPb2U=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/knadh/go-pop3 v0.3.0 h1:h6wh28lyT/vUBMSiSwDDUXZjHH6zL8CM8WYCPbETM4Y=
github.com/knadh/go-pop3 v0.3.0/go.mod h1:a5kUJzrBB6kec+tNJl+3Z64ROgByKBdcyub+mhZMAfI=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=

23
main.go
View File

@ -8,6 +8,8 @@ import (
"text/template"
"time"
"github.com/gorilla/mux"
"git.teamworkapps.com/shortcut/forms"
"github.com/knadh/go-pop3"
)
@ -19,6 +21,15 @@ type tplData struct {
Body string
}
func mwLog(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
log.Printf("%s %s", r.RemoteAddr, r.URL.String())
next.ServeHTTP(w, r)
})
}
func main() {
forms.GlobalStyles.ContainerClasses = "w-full bg-gray-100 justify-center py-6 rounded-lg shadow flex"
@ -74,13 +85,15 @@ func main() {
}
var d tplData
s := http.NewServeMux()
s.HandleFunc("style.css", http.FileServer(http.Dir("./")).ServeHTTP)
s.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
r := mux.NewRouter()
r.Use(mwLog)
r.HandleFunc("/style.css", http.FileServer(http.Dir("./")).ServeHTTP)
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
d.Body = f.Render(true)
tmpl.Execute(w, d)
})
s.HandleFunc("/changepassword", func(w http.ResponseWriter, r *http.Request) {
r.HandleFunc("/changepassword", func(w http.ResponseWriter, r *http.Request) {
if f.Validate(r) != nil {
d.Body = f.Render(true)
tmpl.Execute(w, d)
@ -111,5 +124,5 @@ func main() {
d.Time = time.Now().Unix()
d.Body = f.Render(true)
tmpl.Execute(os.Stdout, d)
http.ListenAndServe(":8910", s)
http.ListenAndServe(":8910", r)
}