diff options
Diffstat (limited to 'httputil/httputil.go')
-rw-r--r-- | httputil/httputil.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/httputil/httputil.go b/httputil/httputil.go new file mode 100644 index 0000000..a03717c --- /dev/null +++ b/httputil/httputil.go | |||
@@ -0,0 +1,25 @@ | |||
1 | // Copyright 2013 The Go Authors. All rights reserved. | ||
2 | // | ||
3 | // Use of this source code is governed by a BSD-style | ||
4 | // license that can be found in the LICENSE file or at | ||
5 | // https://developers.google.com/open-source/licenses/bsd. | ||
6 | |||
7 | // Package httputil is a toolkit for the Go net/http package. | ||
8 | package httputil | ||
9 | |||
10 | import ( | ||
11 | "net" | ||
12 | "net/http" | ||
13 | ) | ||
14 | |||
15 | // StripPort removes the port specification from an address. | ||
16 | func StripPort(s string) string { | ||
17 | if h, _, err := net.SplitHostPort(s); err == nil { | ||
18 | s = h | ||
19 | } | ||
20 | return s | ||
21 | } | ||
22 | |||
23 | // Error defines a type for a function that accepts a ResponseWriter for | ||
24 | // a Request with the HTTP status code and error. | ||
25 | type Error func(w http.ResponseWriter, r *http.Request, status int, err error) | ||