Added request methods
This commit is contained in:
parent
a9b1b3f9c1
commit
cfe9f0622d
3 changed files with 17 additions and 8 deletions
31
parseURL.go
31
parseURL.go
|
@ -1,31 +0,0 @@
|
|||
package web
|
||||
|
||||
import "strings"
|
||||
|
||||
// parseURL parses a URL and returns the scheme, host, path and query.
|
||||
func parseURL(url string) (scheme string, host string, path string, query string) {
|
||||
schemePos := strings.Index(url, "://")
|
||||
|
||||
if schemePos != -1 {
|
||||
scheme = url[:schemePos]
|
||||
url = url[schemePos+len("://"):]
|
||||
}
|
||||
|
||||
pathPos := strings.IndexByte(url, '/')
|
||||
|
||||
if pathPos != -1 {
|
||||
host = url[:pathPos]
|
||||
url = url[pathPos:]
|
||||
}
|
||||
|
||||
queryPos := strings.IndexByte(url, '?')
|
||||
|
||||
if queryPos != -1 {
|
||||
path = url[:queryPos]
|
||||
query = url[queryPos+1:]
|
||||
return
|
||||
}
|
||||
|
||||
path = url
|
||||
return
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue