Skip to content

Commit a57e829

Browse files
committed
move to top dir
1 parent 364664d commit a57e829

19 files changed

+101
-38
lines changed

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# generate jsonenums for APIs
2+
generate:
3+
cd pkg/client && go generate
4+
5+
# generate proto file for Functions module
6+
proto:
7+
go get github.com/mitchellh/protoc-gen-go-json
8+
protoc --gofast_out=. --go-json_out=. pkg/apis/reactor/v1/reactor.proto
9+
10+
test:
11+
go test -v -failfast `go list ./... | egrep -v /tests/`

README.md

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,67 @@ Currently available features:
77
- [x] Inputs
88
- [x] Outputs
99
- [x] Domain reservations
10-
- [ ] Tokens
11-
- [ ] Functions
12-
- [ ] Tunnels
13-
- [ ] Regions
10+
- [x] Tokens
11+
- [x] Functions
12+
- [ ] Function execution logs
13+
- [x] Tunnels
14+
- [x] Regions
15+
- [ ] Webhook Logs
1416

1517
## Installation
1618

1719
You need a working [Go](https://golang.org/) environment.
1820

1921
```shell
2022
go get github.com/webhookrelay/webhookrelay-go
23+
```
24+
25+
## Usage
26+
27+
```golang
28+
package main
29+
30+
import (
31+
"fmt"
32+
"log"
33+
"os"
34+
35+
"github.com/webhookrelay/webhookrelay-go"
36+
)
37+
38+
func main() {
39+
// Construct a new Webhook Relay API object to perform requests
40+
api, err := webhookrelay.New(os.Getenv("RELAY_KEY"), os.Getenv("RELAY_SECRET"))
41+
if err != nil {
42+
log.Fatal(err)
43+
}
44+
45+
bucket, err := api.CreateBucket(&webhookrelay.BucketCreateOptions{
46+
Name: "sendgrid-to-segment",
47+
})
48+
if err != nil {
49+
log.Fatal(err)
50+
}
51+
// all buckets get a default input that you can use to receive webhooks,
52+
// it can either be used with custom domain + path prefix (https://xxx.hooks.webhookrelay.com)
53+
// or input ID such as https://my.webhookrelay.com/v1/webhooks/xxx
54+
fmt.Println(bucket.Inputs[0].EndpointURL())
55+
56+
// Create a webhook forwarding destination for this webhook
57+
_, err = api.CreateOutput(&webhookrelay.Output{
58+
BucketID: bucket.ID,
59+
Name: "segment",
60+
Destination: "https://webhooks.segment.com?b=yyyy",
61+
})
62+
if err != nil {
63+
log.Fatal(err)
64+
}
65+
66+
// list all buckets
67+
buckets, err := api.ListBuckets(&webhookrelay.BucketListOptions{})
68+
if err != nil {
69+
log.Fatal(err)
70+
}
71+
fmt.Println(buckets) // print buckets
72+
}
2173
```

pkg/client/access_tokens.go renamed to access_tokens.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package client
1+
package webhookrelay
22

33
import (
44
"encoding/json"

pkg/client/authtype_jsonenums.go renamed to authtype_jsonenums.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// generated by jsonenums -type=AuthType; DO NOT EDIT
22

3-
package client
3+
package webhookrelay
44

55
import (
66
"encoding/json"

pkg/client/buckets.go renamed to buckets.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package client
1+
package webhookrelay
22

33
import (
44
"encoding/json"

pkg/client/buckets_test.go renamed to buckets_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package client
1+
package webhookrelay
22

33
import (
44
"os"

pkg/client/domains.go renamed to domains.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package client
1+
package webhookrelay
22

33
import (
44
"encoding/json"

pkg/client/errors.go renamed to errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package client
1+
package webhookrelay
22

33
import "errors"
44

pkg/client/functions.go renamed to functions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package client
1+
package webhookrelay
22

33
import (
44
"encoding/json"

pkg/client/inputs.go renamed to inputs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package client
1+
package webhookrelay
22

33
import (
44
"encoding/json"

0 commit comments

Comments
 (0)