Skip to content

Commit

Permalink
Create 0.1.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
marysieek committed Jun 30, 2020
1 parent a9c5e12 commit 7b576d6
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 24 deletions.
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# castle-go

castle-go is a go library wrapping https://castle.io API.
castle-go is a go library wrapping https://castle.io API.

## Install

```
go get github.com/castle/castle-go/castle
go get github.com/castle/castle-go
```

## Usage
Expand All @@ -20,36 +20,36 @@ castle.NewWithHTTPClient("secret-api-key", &http.Client{Timeout: time.Second * 2

```go
castle.Track(
castle.EventLoginSucceeded,
"user-123",
map[string]string{"prop1": "propValue1"},
map[string]string{"trait1": "traitValue1"},
castle.ContextFromRequest(req),
)
castle.EventLoginSucceeded,
"user-123",
map[string]string{"prop1": "propValue1"},
map[string]string{"trait1": "traitValue1"},
castle.ContextFromRequest(req),
)
```

### Tracking custom events

```go
castle.Track(
castle.Event("custom-event"),
"user-123",
map[string]string{"prop1": "propValue1"},
map[string]string{"trait1": "traitValue1"},
castle.ContextFromRequest(req),
)
castle.Event("custom-event"),
"user-123",
map[string]string{"prop1": "propValue1"},
map[string]string{"trait1": "traitValue1"},
castle.ContextFromRequest(req),
)
```

### Adaptive authentication

```go
decision, err := castle.Authenticate(
castle.EventLoginSucceeded,
"md-1",
map[string]string{"prop1": "propValue1"},
map[string]string{"trait1": "traitValue1"},
castle.ContextFromRequest(req),
)
castle.EventLoginSucceeded,
"md-1",
map[string]string{"prop1": "propValue1"},
map[string]string{"trait1": "traitValue1"},
castle.ContextFromRequest(req),
)
```

### Example
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions castle/castle_test.go → castle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http/httptest"
"testing"

"github.com/castle/castle-go/castle"
"github.com/castle/castle-go"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -201,12 +201,12 @@ func TestContextFromRequest(t *testing.T) {

// grabs whitelisted headers only

for _, whitelistedHeader := range castle.HeaderWhitelist {
for _, whitelistedHeader := range castle.HeaderAllowList {
req.Header.Set(whitelistedHeader, whitelistedHeader)
}

ctx = castle.ContextFromRequest(req)
for _, whitelistedHeader := range castle.HeaderWhitelist {
for _, whitelistedHeader := range castle.HeaderAllowList {
assert.Contains(t, ctx.Headers, http.CanonicalHeaderKey(whitelistedHeader))
}

Expand Down
2 changes: 1 addition & 1 deletion castle/go.mod → go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/castle/castle-go/castle
module github.com/castle/castle-go

go 1.14

Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package castle

// VERSION - current package version
const VERSION = "0.1.0"

0 comments on commit 7b576d6

Please sign in to comment.