You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

26 rivejä
711 B

  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. // Package httputil is a toolkit for the Go net/http package.
  7. package httputil
  8. import (
  9. "net"
  10. "net/http"
  11. )
  12. // StripPort removes the port specification from an address.
  13. func StripPort(s string) string {
  14. if h, _, err := net.SplitHostPort(s); err == nil {
  15. s = h
  16. }
  17. return s
  18. }
  19. // Error defines a type for a function that accepts a ResponseWriter for
  20. // a Request with the HTTP status code and error.
  21. type Error func(w http.ResponseWriter, r *http.Request, status int, err error)