Use url.JoinPath instead of path.Join for URLs.

dev-old
Francesco Minnocci 2 years ago
parent d7f9f2935d
commit 6f308377ef
Signed by: BachoSeven
GPG Key ID: 2BE4AB7FDAD828A4

@ -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
}

Loading…
Cancel
Save