arcast/pkg/client/cast.go

28 lines
498 B
Go
Raw Permalink Normal View History

2023-12-13 20:07:22 +01:00
package client
import (
"context"
"fmt"
"forge.cadoles.com/arcad/arcast/pkg/server"
"github.com/pkg/errors"
)
type Status = server.StatusResponse
func (c *Client) Cast(ctx context.Context, addr string, url string) (*Status, error) {
endpoint := fmt.Sprintf("http://%s/api/v1/cast", addr)
req := &server.CastRequest{
URL: url,
}
res := &server.StatusResponse{}
if err := c.apiPost(ctx, endpoint, &req, &res); err != nil {
return nil, errors.WithStack(err)
}
return res, nil
}