added SSL
Some checks failed
Build bang-server / Explore-Gitea-Actions (push) Failing after 12s

This commit is contained in:
Brandon4466
2025-06-08 21:00:22 -07:00
parent 1a5b4f70a7
commit 84b28a1790

11
bang.go
View File

@@ -331,12 +331,19 @@ func withCORS(handler http.HandlerFunc) http.HandlerFunc {
func main() { func main() {
port := flag.Int("port", 8080, "port to listen on") port := flag.Int("port", 8080, "port to listen on")
certFile := flag.String("cert", "/etc/lighttpd/ssl/cert.pem", "path to SSL certificate file")
keyFile := flag.String("key", "/etc/lighttpd/ssl/key.pem", "path to SSL key file")
flag.Parse() flag.Parse()
http.HandleFunc("/users", withCORS(createUserHandler)) http.HandleFunc("/users", withCORS(createUserHandler))
http.HandleFunc("/email", withCORS(receiveEmailHandler)) http.HandleFunc("/email", withCORS(receiveEmailHandler))
http.HandleFunc("/mailbox", withCORS(listMailboxHandler)) http.HandleFunc("/mailbox", withCORS(listMailboxHandler))
http.HandleFunc("/mailbox/open", withCORS(markEmailOpenedHandler)) http.HandleFunc("/mailbox/open", withCORS(markEmailOpenedHandler))
log.Printf("Email server running on :%d", *port) log.Printf("Email server running with SSL on :%d", *port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil)) log.Fatal(http.ListenAndServeTLS(
fmt.Sprintf(":%d", *port),
*certFile,
*keyFile,
nil,
))
} }