12345678910111213141516171819202122232425262728293031323334353637 |
- package main
- import (
- "log"
- "net/http"
- "os"
- "time"
- "code.osinet.fr/fgm/web_auth_demo/server"
- )
- func main() {
- app, err := server.New(
- os.Getenv("AUTH_USERNAME"),
- os.Getenv("AUTH_PASSWORD"),
- os.Getenv("AUTH_CERT"),
- os.Getenv("AUTH_CERT_KEY"),
- )
- if err != nil {
- log.Fatal(err)
- }
- mux := http.NewServeMux()
- mux.HandleFunc("/unprotected", app.UnprotectedHandler)
- mux.HandleFunc("/protected", app.BasicAuth(app.ProtectedHandler))
- srv := &http.Server{
- Addr: ":4000",
- Handler: mux,
- ReadTimeout: 10 * time.Second,
- WriteTimeout: 30 * time.Second,
- IdleTimeout: time.Minute,
- }
- log.Printf("Starting TLS server on %s", srv.Addr)
- err = srv.ListenAndServeTLS(app.Cert, app.Key)
- log.Fatal(err)
- }
|