Compare commits
3 commits
68a5f0d2e9
...
459d10664a
Author | SHA1 | Date | |
---|---|---|---|
459d10664a | |||
10d174f626 | |||
af3d980252 |
1 changed files with 6 additions and 3 deletions
|
@ -36,6 +36,7 @@ func main() {
|
|||
return
|
||||
}
|
||||
stmt = sel_stmt
|
||||
defer sel_stmt.Close()
|
||||
|
||||
fasthttp.ListenAndServe("127.0.0.1:4001", handler)
|
||||
}
|
||||
|
@ -59,7 +60,7 @@ func handler(ctx *fasthttp.RequestCtx) {
|
|||
row := stmt.QueryRow(
|
||||
ctx.Method(),
|
||||
fmt.Sprintf(
|
||||
"%s://%s:%d%s",
|
||||
"%s://%s:%s%s",
|
||||
scheme,
|
||||
host,
|
||||
port,
|
||||
|
@ -113,15 +114,17 @@ func handler(ctx *fasthttp.RequestCtx) {
|
|||
|
||||
func parseHost(host []byte, https bool) ([]byte, []byte) {
|
||||
idx := bytes.LastIndex(host, []byte(":"))
|
||||
var port []byte
|
||||
var resHost, port []byte
|
||||
if idx != -1 {
|
||||
resHost = host[:idx]
|
||||
port = host[idx+1:]
|
||||
} else {
|
||||
resHost = host
|
||||
if https {
|
||||
port = []byte("443")
|
||||
} else {
|
||||
port = []byte("80")
|
||||
}
|
||||
}
|
||||
return host[:idx], port
|
||||
return resHost, port
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue