Commit 2248b004 authored by Geoff Simmons's avatar Geoff Simmons

Substringing more efficient and go-like.

parent 8a527944
......@@ -46,6 +46,7 @@ import (
var (
hostname string
logger *log.Logger
lenPrefix int
address = flag.String("address", ":7357", "listen address")
logF = flag.String("log", "", "log file (default stdout)")
setPrefix = flag.String("set_prefix", "X-Set-",
......@@ -81,7 +82,7 @@ func handle(resp http.ResponseWriter, req *http.Request) {
if !strings.HasPrefix(reqHdr, *setPrefix) {
continue
}
newHdr := string([]byte(reqHdr)[len(*setPrefix):])
newHdr := reqHdr[lenPrefix:]
for _, val := range vals {
respHdr.Add(newHdr, val)
}
......@@ -129,6 +130,7 @@ func main() {
hostname = "unknown"
}
lenPrefix = len(*setPrefix)
mux := http.NewServeMux()
mux.HandleFunc("/", handle)
logger.Println("listening at:", *address)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment