-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.go
48 lines (38 loc) · 1.12 KB
/
server.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
package main
import (
"github.com/urfave/cli"
"github.com/Skyhark-Projects/golang-bic-from-iban/http"
"github.com/Skyhark-Projects/golang-bic-from-iban/log"
"github.com/Skyhark-Projects/golang-bic-from-iban/bic"
"errors"
)
func loadBicsDB() {
bic.LoadBelgiumList("data/be-swift-codes.json")
bic.LoadIbanRules("data/ibanrules.csv")
bic.LoadAllCountries()
}
func RunServer(c *cli.Context) error {
loadBicsDB()
http.AddRoute("/iban/:iban", func(req http.Request) (interface{}, error) {
bank := bic.GetInfo(req.Variables["iban"])
return bank, nil
})
/*http.AddRoute("/swift/:swift", func(req http.Request) (interface{}, error) {
bank := bic.GetInfo(req.Variables["iban"])
return bank, nil
})*/
//ToDo test othe countries outside belgium, starting with DE, Nl, FR
//log.Info("test", "iban", bank)
http.Start("8080")
return nil
}
func TransformBePdfCmd(c *cli.Context) error {
if len(c.Args()) == 0 {
return errors.New("No path provided")
}
if err := bic.BeListToJSON(c.Args()[0]); err != nil {
return err
}
log.Info("PDF Banks lists converted to json")
return nil
}