This commit is contained in:
Simon Ser 2022-02-21 11:11:27 +01:00
parent 5a641ceca1
commit 13008e0d96
2 changed files with 4 additions and 4 deletions

View File

@ -25,7 +25,7 @@ func NewIMAP(addr string, tls bool) AuthProvider {
} }
func (prov *IMAPProvider) Middleware() func(http.Handler) http.Handler { func (prov *IMAPProvider) Middleware() func(http.Handler) http.Handler {
return func (next http.Handler) http.Handler { return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
prov.doAuth(next, w, r) prov.doAuth(next, w, r)
}) })

View File

@ -5,7 +5,7 @@ import (
"log" "log"
"net/http" "net/http"
"os" "os"
"github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware" "github.com/go-chi/chi/v5/middleware"
@ -31,11 +31,11 @@ func main() {
authProvider := auth.NewIMAP("imap.migadu.com:993", true) authProvider := auth.NewIMAP("imap.migadu.com:993", true)
mux.Use(authProvider.Middleware()) mux.Use(authProvider.Middleware())
mux.Get("/", func (w http.ResponseWriter, r *http.Request) { mux.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello world!\n")) w.Write([]byte("Hello world!\n"))
}) })
server := http.Server { server := http.Server{
Addr: addr, Addr: addr,
Handler: mux, Handler: mux,
} }