Added request headers

This commit is contained in:
Eduard Urbach 2024-03-27 22:12:16 +01:00
parent 78a628abbe
commit 82dd83c701
Signed by: eduard
GPG key ID: 49226B848C78F6C8
6 changed files with 131 additions and 65 deletions

31
parseURL.go Normal file
View file

@ -0,0 +1,31 @@
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
}