-
Notifications
You must be signed in to change notification settings - Fork 0
/
bible_net.go
63 lines (49 loc) · 1.2 KB
/
bible_net.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package biblepassageapi
import (
"io/ioutil"
"net/http"
"net/url"
)
type BibleNET struct{}
func NewBibleNET() BibleNET {
return BibleNET{}
}
func (b BibleNET) Source() string {
return "netbibleapi"
}
func (b BibleNET) NameShort() string {
return "NET"
}
func (b BibleNET) NameCommon() string {
return "NET Bible"
}
func (b BibleNET) Name() string {
return "New English Translation Bible"
}
func (b BibleNET) GetPassage(reference string) (*Passage, error) {
q := url.Values{}
q.Add("formatting", "full")
q.Add("passage", reference)
u := url.URL{
Scheme: "http",
Host: "labs.bible.org",
Path: "/api/",
RawQuery: q.Encode(),
}
client := &http.Client{}
req, _ := http.NewRequest("GET", u.String(), nil)
res, err := client.Do(req)
if err != nil {
return nil, err
}
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return nil, err
}
passage := Passage{
Html: string(body),
TrackingCode: "",
Copyright: "Scripture quoted by permission. All scripture quotations, unless otherwise indicated, are taken from the NET Bible® copyright ©1996-2006 by Biblical Studies Press, L.L.C. http://netbible.com All rights reserved.",
}
return &passage, nil
}