跳转到某个URL
(writer http.ResponseWriter, req *http.Request, url string, code int)
| 219 | |
| 220 | // 跳转到某个URL |
| 221 | func httpRedirect(writer http.ResponseWriter, req *http.Request, url string, code int) { |
| 222 | if len(writer.Header().Get("Content-Type")) == 0 { |
| 223 | // 设置Content-Type,是为了让页面不输出链接 |
| 224 | writer.Header().Set("Content-Type", "text/html; charset=utf-8") |
| 225 | } |
| 226 | |
| 227 | http.Redirect(writer, req, url, code) |
| 228 | } |
| 229 | |
| 230 | // 分析URL中的Host部分 |
| 231 | func httpParseHost(urlString string) (host string, err error) { |
no test coverage detected