-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
48 lines (40 loc) · 1.14 KB
/
main.go
File metadata and controls
48 lines (40 loc) · 1.14 KB
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 to run base/boot application
package main
import (
//"fmt"
"github.com/ashurai/BitUpdater/handler"
"github.com/ashurai/BitUpdater/model"
"log"
"net/http"
"sync"
"github.com/gorilla/mux"
)
// PreSymbolsList configure your list of symbols
var PreSymbolsList = []string{"BTCUSD", "ETHBTC"}//, "FGVTCJ"}//, "FGVTCJ"}
// innvalid for test = FGVTCJ, another valid value for test = FGVTCJ
// Use the symbole type from handler
// which is importing struct from models
var sy *handler.Symbol
func main() {
var wg sync.WaitGroup
lenOfSy := len(PreSymbolsList)
valChan := make(chan model.Symbol, lenOfSy)
// Validate all the valid symbols
wg.Add(lenOfSy)
sy.ValidateSymbols(PreSymbolsList, &wg, valChan)
wg.Wait()
close(valChan)
result := []model.Symbol{}
for ch := range valChan {
result = append(result, ch)
}
log.Println(result)
log.Println("start localhost")
handleRequests()
}
func handleRequests() {
router := mux.NewRouter().StrictSlash(true)
router.HandleFunc("/currency/all", handler.GetAllCurrency)
router.HandleFunc("/currency/{currency}", handler.GetCurrencyByID)
log.Fatal(http.ListenAndServe(":8099", router))
}