File tree 1 file changed +11
-7
lines changed
1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 5
5
"log"
6
6
"net"
7
7
"net/http"
8
- "net/url"
9
8
"strings"
10
9
"time"
11
10
)
@@ -24,19 +23,24 @@ func (s *Server) ListenAndServe() {
24
23
}
25
24
26
25
func (s * Server ) ServeHTTP () {
27
- u , err := url .Parse (s .Opts .HttpAddress )
28
- if err != nil {
29
- log .Fatalf ("FATAL: could not parse %#v: %v" , s .Opts .HttpAddress , err )
26
+ httpAddress := s .Opts .HttpAddress
27
+ scheme := ""
28
+
29
+ i := strings .Index (httpAddress , "://" )
30
+ if i > - 1 {
31
+ scheme = httpAddress [0 :i ]
30
32
}
31
33
32
34
var networkType string
33
- switch u . Scheme {
35
+ switch scheme {
34
36
case "" , "http" :
35
37
networkType = "tcp"
36
38
default :
37
- networkType = u . Scheme
39
+ networkType = scheme
38
40
}
39
- listenAddr := strings .TrimPrefix (u .String (), u .Scheme + "://" )
41
+
42
+ slice := strings .SplitN (httpAddress , "//" , 2 )
43
+ listenAddr := slice [len (slice )- 1 ]
40
44
41
45
listener , err := net .Listen (networkType , listenAddr )
42
46
if err != nil {
You can’t perform that action at this time.
0 commit comments