Add support for the "Open" action
This commit is contained in:
@ -13,6 +13,7 @@ import (
|
||||
|
||||
const (
|
||||
urlPath = "/url/open"
|
||||
openPath = "/cmd/open"
|
||||
)
|
||||
|
||||
type RemoteClient struct {
|
||||
@ -32,6 +33,22 @@ func New(host, token string) *RemoteClient {
|
||||
return &RemoteClient{client: client, baseUrl: "https://" + host, token: token}
|
||||
}
|
||||
|
||||
func (r *RemoteClient) Open(path string) error {
|
||||
formData := url.Values{
|
||||
"path": {path},
|
||||
}
|
||||
|
||||
status, _, err := r.doRequest(openPath, formData)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if status != http.StatusOK {
|
||||
return errors.New("invalid status: " + strconv.Itoa(status))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *RemoteClient) OpenURL(urlStr string) error {
|
||||
formData := url.Values{
|
||||
"url": {urlStr},
|
||||
|
Reference in New Issue
Block a user