Skip to content

Commit

Permalink
updated main.go
Browse files Browse the repository at this point in the history
  • Loading branch information
alash3al committed Jun 20, 2023
1 parent cbd821b commit adbf9a5
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"log"
"net/http"

"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
Expand All @@ -19,9 +20,6 @@ func main() {
UserAgent: "https://github.com/alash3al/httpsify",
}

httpChallengeHandler := e.AutoTLSManager.HTTPHandler(nil)

e.Use(middleware.HTTPSRedirect())
e.Use(middleware.Logger())
e.Use(middleware.Recover())
e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
Expand All @@ -30,10 +28,6 @@ func main() {
c.Response().Header().Set("X-Secured-By", "https://github.com/alash3al/httpsify")
}

if !c.IsTLS() {
return echo.WrapHandler(httpChallengeHandler)(c)
}

hosts := hosts.Load().(map[string]*echo.Echo)
host := hosts[c.Request().Host]

Expand All @@ -48,7 +42,7 @@ func main() {
errChan := make(chan error)

go (func() {
errChan <- e.Start(*flagHTTPAddr)
errChan <- http.ListenAndServe(*flagHTTPAddr, e.AutoTLSManager.HTTPHandler(nil))
})()

go (func() {
Expand Down

0 comments on commit adbf9a5

Please sign in to comment.