Documentation
¶
Overview ¶
Package ngrok simplifies interaction with the ngrok API.
This client is not endpoint compatible with the API - many endpoints are missing. Still, it should be trivial to add new *Service objects and endpoints, following the existing pattern.
For more information on the ngrok API, see the documentation:
https://ngrok.com/docs/ngrok-link#service-api
Example ¶
package main import ( "context" "fmt" "log" "net/url" "os" ngrok "github.com/meterup/ngrok-go" ) func main() { client := ngrok.New(ngrok.BaseURL, os.Getenv("NGROK_API_TOKEN")) data := url.Values{} data.Set("description", "ngrok-go") cred, err := client.Creds.Create(context.TODO(), data) if err != nil { log.Fatal(err) } fmt.Printf("created credential: %#v\n", cred) }
Output:
Index ¶
- Constants
- type Client
- func (c *Client) CreateResource(ctx context.Context, pathPart string, data url.Values, v interface{}) error
- func (c *Client) DeleteResource(ctx context.Context, pathPart string, sid string) error
- func (c *Client) GetResource(ctx context.Context, pathPart string, sid string, v interface{}) error
- func (c *Client) ListResource(ctx context.Context, pathPart string, data url.Values, v interface{}) error
- func (c *Client) MakeRequest(ctx context.Context, method string, pathPart string, data url.Values, ...) error
- func (c *Client) NewRequest(ctx context.Context, method, path string, body io.Reader) (*http.Request, error)
- func (c *Client) UpdateResource(ctx context.Context, pathPart string, sid string, data url.Values, ...) error
- type Cred
- type CredService
- type Region
- type ReservedAddr
- type ReservedAddrService
Examples ¶
Constants ¶
View Source
const BaseURL = "https://api.ngrok.com"
View Source
const Version = "0.1"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { *rest.Client Creds *CredService ReservedAddrs *ReservedAddrService // contains filtered or unexported fields }
func (*Client) CreateResource ¶
func (c *Client) CreateResource(ctx context.Context, pathPart string, data url.Values, v interface{}) error
CreateResource makes a POST request to the given resource.
func (*Client) DeleteResource ¶
func (*Client) GetResource ¶
GetResource retrieves an instance resource with the given path part (e.g. "/Messages") and sid (e.g. "MM123").
func (*Client) ListResource ¶
func (*Client) MakeRequest ¶
func (c *Client) MakeRequest(ctx context.Context, method string, pathPart string, data url.Values, v interface{}) error
Make a request to the ngrok API.
type Cred ¶
type Cred struct { // Only present on the response from a Create request, otherwise empty Token string `json:"token"` Description string `json:"description"` ACL []string `json:"acl"` CreatedAt time.Time `json:"created_at"` ID string `json:"id"` Metadata string `json:"metadata"` URI string `json:"uri"` }
type CredService ¶
type CredService struct {
// contains filtered or unexported fields
}
func (*CredService) Create ¶
Create a new Credential. https://ngrok.com/docs/ngrok-link#create-credential
type Region ¶
type Region string
const RegionAP Region = "ap"
const RegionAU Region = "au"
const RegionEU Region = "eu"
const RegionUS Region = "us"
type ReservedAddr ¶
type ReservedAddr struct { Addr string `json:"addr"` CreatedAt time.Time `json:"created_at"` Description string `json:"description"` ID string `json:"id"` Metadata string `json:"metadata"` Region string `json:"region"` URI string `json:"uri"` EndpointConfiguration map[string]string `json:"endpoint_configuration"` }
type ReservedAddrService ¶
type ReservedAddrService struct {
// contains filtered or unexported fields
}
func (*ReservedAddrService) Create ¶
func (c *ReservedAddrService) Create(ctx context.Context, data url.Values) (*ReservedAddr, error)
Click to show internal directories.
Click to hide internal directories.