@@ -5,12 +5,15 @@ import (
5
5
"flag"
6
6
"fmt"
7
7
"log"
8
+ "net"
8
9
"net/http"
10
+ "runtime/debug"
9
11
"time"
10
12
11
13
"github.com/gofiber/fiber/v2"
12
14
"github.com/gofiber/fiber/v2/middleware/recover"
13
15
"github.com/gofiber/fiber/v2/middleware/session"
16
+ "github.com/gofiber/fiber/v2/utils"
14
17
"github.com/gofiber/storage/memory"
15
18
)
16
19
@@ -26,8 +29,23 @@ func main() {
26
29
var port string
27
30
flag .StringVar (& port , "p" , "8091" , "listening port" )
28
31
flag .Parse ()
29
- // TODO configure transport
30
- client := & http.Client {}
32
+
33
+ // DefaultTransport without ForceAttemptHTTP2 (temporarily disable HTTP2)
34
+ // TODO enable http2 as soon as the bug https://github.com/golang/go/issues/47882 is fixed
35
+ client := & http.Client {
36
+ Transport : & http.Transport {
37
+ Proxy : http .ProxyFromEnvironment ,
38
+ DialContext : (& net.Dialer {
39
+ Timeout : 30 * time .Second ,
40
+ KeepAlive : 30 * time .Second ,
41
+ }).DialContext ,
42
+ MaxIdleConns : 100 ,
43
+ IdleConnTimeout : 90 * time .Second ,
44
+ TLSHandshakeTimeout : 10 * time .Second ,
45
+ ExpectContinueTimeout : 1 * time .Second ,
46
+ },
47
+ }
48
+
31
49
// TODO static map www.example.com -> mail.com (from config file)
32
50
conv := NewDomainConverter ("host.juicyrout:" + port )
33
51
conv .AddStaticMapping ("www.w3.org" , "www.w3.org" )
@@ -61,6 +79,10 @@ func main() {
61
79
62
80
app .Use (recover .New (recover.Config {
63
81
EnableStackTrace : true ,
82
+ StackTraceHandler : func (e interface {}) {
83
+ log .Println ("panic: " , e )
84
+ log .Println ("stack: " , utils .UnsafeString (debug .Stack ()))
85
+ },
64
86
}))
65
87
auth := NewAuthMiddleware (AuthConfig {
66
88
CookieName : "session_id" ,
0 commit comments