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