fix request paths
This commit is contained in:
parent
8192244fec
commit
abeb9655f9
|
@ -3,7 +3,7 @@ package panelapi
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pterodactyl/wings/api"
|
"github.com/pterodactyl/wings/api"
|
||||||
|
@ -35,8 +35,9 @@ func CreateClient(base, tokenId, token string, opts ...ClientOption) Client {
|
||||||
httpClient := &http.Client{
|
httpClient := &http.Client{
|
||||||
Timeout: time.Second * 15,
|
Timeout: time.Second * 15,
|
||||||
}
|
}
|
||||||
|
base = strings.TrimSuffix(base, "/")
|
||||||
c := &client{
|
c := &client{
|
||||||
baseUrl: filepath.Join(base, "api/remote"),
|
baseUrl: base + "/api/remote",
|
||||||
tokenId: tokenId,
|
tokenId: tokenId,
|
||||||
token: token,
|
token: token,
|
||||||
httpClient: httpClient,
|
httpClient: httpClient,
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
"github.com/pterodactyl/wings/system"
|
"github.com/pterodactyl/wings/system"
|
||||||
)
|
)
|
||||||
|
@ -35,7 +34,7 @@ type q map[string]string
|
||||||
// Prefer request() over this method when possible.
|
// Prefer request() over this method when possible.
|
||||||
// It appends the path to the endpoint of the client and adds the authentication token to the request.
|
// It appends the path to the endpoint of the client and adds the authentication token to the request.
|
||||||
func (c *client) requestOnce(ctx context.Context, method, path string, body io.Reader, opts ...func(r *http.Request)) (*Response, error) {
|
func (c *client) requestOnce(ctx context.Context, method, path string, body io.Reader, opts ...func(r *http.Request)) (*Response, error) {
|
||||||
req, err := http.NewRequest(method, filepath.Join(c.baseUrl, path), body)
|
req, err := http.NewRequest(method, c.baseUrl+path, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user