Skip to content

Commit

Permalink
fix: added endpoint prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
mojtaba-esk committed Dec 6, 2023
1 parent b405757 commit 6cfcf07
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
"go.uber.org/zap"
)

const baseUrl = "/api/v1"
const EndpointPrefix = "/api/v1"

func path(endpoint string) string {
return baseUrl + endpoint
return EndpointPrefix + endpoint
}

func NewRESTApiV1(productionMode bool, logger *zap.Logger) *RESTApiV1 {
Expand Down
22 changes: 12 additions & 10 deletions sdk/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,52 @@ import (
"github.com/celestiaorg/bittwister/api/v1"
)

const endpointPrefix = api.EndpointPrefix

type PacketLossStartRequest = api.PacketLossStartRequest
type BandwidthStartRequest = api.BandwidthStartRequest
type LatencyStartRequest = api.LatencyStartRequest
type ServiceStatus = api.ServiceStatus
type MetaMessage = api.MetaMessage

func (c *Client) PacketlossStart(req PacketLossStartRequest) error {
return c.postServiceAction("/packetloss/start", req)
return c.postServiceAction(endpointPrefix+"/packetloss/start", req)
}

func (c *Client) PacketlossStop() error {
return c.postServiceAction("/packetloss/stop", nil)
return c.postServiceAction(endpointPrefix+"/packetloss/stop", nil)
}

func (c *Client) PacketlossStatus() (*MetaMessage, error) {
return c.getServiceStatus("/packetloss/status")
return c.getServiceStatus(endpointPrefix + "/packetloss/status")
}

func (c *Client) BandwidthStart(req BandwidthStartRequest) error {
return c.postServiceAction("/bandwidth/start", req)
return c.postServiceAction(endpointPrefix+"/bandwidth/start", req)
}

func (c *Client) BandwidthStop() error {
return c.postServiceAction("/bandwidth/stop", nil)
return c.postServiceAction(endpointPrefix+"/bandwidth/stop", nil)
}

func (c *Client) BandwidthStatus() (*MetaMessage, error) {
return c.getServiceStatus("/bandwidth/status")
return c.getServiceStatus(endpointPrefix + "/bandwidth/status")
}

func (c *Client) LatencyStart(req LatencyStartRequest) error {
return c.postServiceAction("/latency/start", req)
return c.postServiceAction(endpointPrefix+"/latency/start", req)
}

func (c *Client) LatencyStop() error {
return c.postServiceAction("/latency/stop", nil)
return c.postServiceAction(endpointPrefix+"/latency/stop", nil)
}

func (c *Client) LatencyStatus() (*MetaMessage, error) {
return c.getServiceStatus("/latency/status")
return c.getServiceStatus(endpointPrefix + "/latency/status")
}

func (c *Client) AllServicesStatus() ([]ServiceStatus, error) {
resp, err := c.getResource("/services/status")
resp, err := c.getResource(endpointPrefix + "/services/status")
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 6cfcf07

Please sign in to comment.