webhookrelay / webhookrelay-go

Go library for the Webhook Relay v1 API

Home Page:https://webhookrelay.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Webhook Relay API Go client

GoDoc

This library is currently actively developed so the API might change a little bit.

Features

Currently available features:

  • Buckets
  • Inputs
  • Outputs
  • Output rules
  • Domain reservations
  • Tokens
  • Functions
  • Function config variables
  • Invoke function
  • Function execution logs
  • Tunnels
  • Regions
  • Webhook Logs

Installation

You need a working Go environment.

go get github.com/webhookrelay/webhookrelay-go

Authentication

To authenticate, you will need to first get an API token key & secret pair here.

Usage

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/webhookrelay/webhookrelay-go"
)

func main() {
	// Construct a new Webhook Relay API object to perform requests
	api, err := webhookrelay.New(os.Getenv("RELAY_KEY"), os.Getenv("RELAY_SECRET"))
	if err != nil {
		log.Fatal(err)
  }
  
  bucket, err := api.CreateBucket(&webhookrelay.BucketCreateOptions{
    Name: "sendgrid-to-segment",
  })
  if err != nil {
		log.Fatal(err)
  }
  // all buckets get a default input that you can use to receive webhooks, 
  // it can either be used with custom domain + path prefix (https://xxx.hooks.webhookrelay.com) 
  // or input ID such as https://my.webhookrelay.com/v1/webhooks/xxx
  fmt.Println(bucket.Inputs[0].EndpointURL()) 

  // Create a webhook forwarding destination for this webhook
  _, err = api.CreateOutput(&webhookrelay.Output{
    BucketID: bucket.ID,
    Name: "segment",
    Destination: "https://webhooks.segment.com?b=yyyy",
  })
  if err != nil {
		log.Fatal(err)
  }

  // list all buckets
  buckets, err := api.ListBuckets(&webhookrelay.BucketListOptions{})
  if err != nil {
		log.Fatal(err)
  }
  fmt.Println(buckets) // print buckets
}

About

Go library for the Webhook Relay v1 API

https://webhookrelay.com

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Go 99.6%Language:Makefile 0.4%