You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
586 B
Go
23 lines
586 B
Go
// Copyright (c) 2015 Dalton Hubble. All rights reserved.
|
|
// Copyrights licensed under the MIT License.
|
|
|
|
package oauth1
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"strings"
|
|
)
|
|
|
|
// baseURI returns the base string URI of a request
|
|
// according to RFC 5849 3.4.1.2.
|
|
func baseURI(r *http.Request) string {
|
|
scheme := strings.ToLower(r.URL.Scheme)
|
|
host := strings.ToLower(r.URL.Host)
|
|
if hostPort := strings.Split(host, ":"); len(hostPort) == 2 && (hostPort[1] == "80" || hostPort[1] == "443") {
|
|
host = hostPort[0]
|
|
}
|
|
path := r.URL.EscapedPath()
|
|
return fmt.Sprintf("%v://%v%v", scheme, host, path)
|
|
}
|