-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.go
61 lines (49 loc) · 1.9 KB
/
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
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"flag"
"fmt"
"log"
"net/http"
"os"
appconfig "github.com/lelledaniele/upaygo/config"
apprestintentcancel "github.com/lelledaniele/upaygo/controller/rest/intent/cancel"
apprestintentcapture "github.com/lelledaniele/upaygo/controller/rest/intent/capture"
apprestintentconfirm "github.com/lelledaniele/upaygo/controller/rest/intent/confirm"
apprestintentcreate "github.com/lelledaniele/upaygo/controller/rest/intent/create"
apprestintentget "github.com/lelledaniele/upaygo/controller/rest/intent/get"
httpSwagger "github.com/swaggo/http-swagger"
"github.com/gorilla/mux"
_ "github.com/lelledaniele/upaygo/docs"
)
var configFile string
func init() {
flag.StringVar(&configFile, "config", "", "Path for config file")
flag.Parse()
if configFile == "" {
log.Fatal("Flag 'config' for configuration file path is required")
}
}
// @title uPayment in GO
// @version 1.0.0
// @description Microservice to manage payment
// @license.name MIT
func main() {
fc, e := os.Open(configFile)
if e != nil {
log.Fatal(fmt.Sprintf("Impossible to open configuration file: %v\n", e))
}
defer fc.Close()
e = appconfig.ImportConfig(fc)
if e != nil {
log.Fatal(fmt.Sprintf("Error durring file config import: %v\n", e))
}
s := appconfig.GetServerConfig()
r := mux.NewRouter()
r.PathPrefix("/swagger/").Handler(httpSwagger.WrapHandler)
r.HandleFunc(apprestintentget.URL, apprestintentget.Handler).Methods(apprestintentget.Method)
r.HandleFunc(apprestintentcreate.URL, apprestintentcreate.Handler).Methods(apprestintentcreate.Method)
r.HandleFunc(apprestintentconfirm.URL, apprestintentconfirm.Handler).Methods(apprestintentconfirm.Method)
r.HandleFunc(apprestintentcapture.URL, apprestintentcapture.Handler).Methods(apprestintentcapture.Method)
r.HandleFunc(apprestintentcancel.URL, apprestintentcancel.Handler).Methods(apprestintentcancel.Method)
log.Fatal(http.ListenAndServe(":"+s.GetPort(), r))
}