File tree Expand file tree Collapse file tree 2 files changed +51
-13
lines changed Expand file tree Collapse file tree 2 files changed +51
-13
lines changed Original file line number Diff line number Diff line change 1
- # LabStack Go Client
1
+ < a href = " https://labstack.com " >< img height = " 80 " src = " https://cdn.labstack.com/images/labstack-logo.svg " ></ a >
2
2
3
+ ## Go Client
3
4
4
- [ ![ GoDoc] ( http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square )] ( http://godoc.org/github.com/labstack/labstack-go )
5
- [ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/labstack/labstack-go?style=flat-square )] ( https://goreportcard.com/report/github.com/labstack/labstack-go )
6
- [ ![ Build Status] ( http://img.shields.io/travis/labstack/labstack-go.svg?style=flat-square )] ( https://travis-ci.org/labstack/labstack-go )
7
- [ ![ Codecov] ( https://img.shields.io/codecov/c/github/labstack/labstack-go.svg?style=flat-square )] ( https://codecov.io/gh/labstack/labstack-go )
8
- [ ![ Forum] ( https://img.shields.io/badge/community-forum-00afd1.svg?style=flat-square )] ( https://forum.labstack.com )
9
- [ ![ Twitter
] ( https://img.shields.io/badge/[email protected] ?style=flat-square )] ( https://twitter.com/labstack )
10
- [ ![ License] ( http://img.shields.io/badge/license-mit-blue.svg?style=flat-square )] ( https://raw.githubusercontent.com/labstack/labstack-go/master/LICENSE )
5
+ ## Installation
6
+
7
+ ` go get github.com/labstack/labstack-go `
8
+
9
+ ## Quick Start
10
+
11
+ [ Sign up] ( https://labstack.com/signup ) to get an API key
12
+
13
+ Create a file ` app.go ` with the following content:
14
+
15
+ ``` go
16
+ package main
17
+
18
+ import (
19
+ " fmt"
20
+
21
+ " github.com/labstack/labstack-go"
22
+ )
23
+
24
+ func main () {
25
+ client := labstack.NewClient (" <ACCOUNT_ID>" , " <API_KEY>" )
26
+ store := client.Store ()
27
+ doc , err := store.Insert (" users" , labstack.Document {
28
+ " name" : " Jack" ,
29
+ " location" : " Disney" ,
30
+ })
31
+ if err != nil {
32
+ panic (err)
33
+ }
34
+ fmt.Printf (" %+v " , doc)
35
+ }
36
+ ```
37
+
38
+ From terminal run your app:
39
+
40
+ ``` sh
41
+ go run app.go
42
+ ```
43
+
44
+ ## [ Docs] ( https://labstack.com/docs ) | [ Forum] ( https://forum.labstack.com )
Original file line number Diff line number Diff line change @@ -9,8 +9,10 @@ import (
9
9
10
10
type (
11
11
Client struct {
12
- sling * sling.Sling
13
- logger * glog.Logger
12
+ accountID string
13
+ apiKey string
14
+ sling * sling.Sling
15
+ logger * glog.Logger
14
16
}
15
17
16
18
Fields map [string ]interface {}
@@ -30,10 +32,12 @@ const (
30
32
)
31
33
32
34
// NewClient creates a new client for the LabStack API.
33
- func NewClient (apiKey string ) * Client {
35
+ func NewClient (accountID , apiKey string ) * Client {
34
36
return & Client {
35
- sling : sling .New ().Base (apiURL ).Add ("Authorization" , "Bearer " + apiKey ),
36
- logger : glog .New ("labstack" ),
37
+ accountID : accountID ,
38
+ apiKey : apiKey ,
39
+ sling : sling .New ().Base (apiURL ).Add ("Authorization" , "Bearer " + apiKey ),
40
+ logger : glog .New ("labstack" ),
37
41
}
38
42
}
39
43
You can’t perform that action at this time.
0 commit comments