feat: initial commit
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good
This commit is contained in:
30
internal/client/create_proxy.go
Normal file
30
internal/client/create_proxy.go
Normal file
@ -0,0 +1,30 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
|
||||
"forge.cadoles.com/cadoles/bouncer/internal/admin"
|
||||
"forge.cadoles.com/cadoles/bouncer/internal/store"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func (c *Client) CreateProxy(ctx context.Context, name store.ProxyName, to *url.URL, from []string, funcs ...OptionFunc) (*store.Proxy, error) {
|
||||
request := admin.CreateProxyRequest{
|
||||
Name: string(name),
|
||||
To: to.String(),
|
||||
From: from,
|
||||
}
|
||||
|
||||
response := withResponse[admin.CreateProxyResponse]()
|
||||
|
||||
if err := c.apiPost(ctx, "/api/v1/proxies", request, &response); err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
if response.Error != nil {
|
||||
return nil, errors.WithStack(response.Error)
|
||||
}
|
||||
|
||||
return response.Data.Proxy, nil
|
||||
}
|
Reference in New Issue
Block a user