Add support for the "Open" action

This commit is contained in:
Tyler
2019-05-21 19:50:47 -04:00
parent 4a7f7eef5f
commit c0f9bdd37b
11 changed files with 74 additions and 14 deletions

View File

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