Use url.JoinPath instead of path.Join for URLs.
This commit is contained in:
+15
-3
@@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"path"
|
||||
urlpkg "net/url"
|
||||
|
||||
"git.phc.dm.unipi.it/phc/website/model"
|
||||
)
|
||||
@@ -44,10 +44,17 @@ func newLDAPAuthService(host string) Service {
|
||||
|
||||
// doGetRequest is a utility to make HTTP GET requests
|
||||
func (a *ldapAuthService) doGetRequest(url string, response interface{}) error {
|
||||
u, err := urlpkg.JoinPath(a.Host, "poisson-ldap", url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
"GET", path.Join(a.Host, "poisson-ldap", url), bytes.NewBuffer([]byte("")),
|
||||
"GET", u, bytes.NewBuffer([]byte("")),
|
||||
)
|
||||
|
||||
log.Printf(`%q`, a.Host)
|
||||
|
||||
if err != nil {
|
||||
log.Printf(`GET %q resulted in %v`, url, err)
|
||||
return err
|
||||
@@ -74,7 +81,12 @@ func (a *ldapAuthService) doPostRequest(url string, request interface{}, respons
|
||||
return err
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("POST", path.Join(a.Host, "ldap", url), bytes.NewBuffer(jsonStr))
|
||||
u, err := urlpkg.JoinPath(a.Host, "ldap", url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("POST", u, bytes.NewBuffer(jsonStr))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user