-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (42 loc) · 887 Bytes
/
main.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
package main
import (
"encoding/json"
"io"
"io/ioutil"
"log"
"github.com/codegangsta/negroni"
"github.com/gorilla/mux"
"github.com/otiai10/gosseract"
r "gopkg.in/dancannon/gorethink.v1"
)
func main() {
// verify tesseract is available...
goss, err := gosseract.NewClient()
if err != nil {
log.Fatalln(err.Error())
}
session, err := r.Connect(r.ConnectOpts{
Address: "localhost:28015",
Database: "test",
})
if err != nil {
log.Fatalln(err.Error())
}
mux := mux.NewRouter()
mux.Handle("/post/new", createImageHandler(goss, NewPostingStore(session))).
Methods("POST")
mw := negroni.Classic()
mw.UseHandler(mux)
mw.Run(":1234")
}
func unmarshal(r io.Reader, v interface{}) (interface{}, error) {
data, err := ioutil.ReadAll(r)
if err != nil {
return nil, err
}
err = json.Unmarshal(data, v)
if err != nil {
return nil, err
}
return v, nil
}