-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
25 lines (22 loc) · 805 Bytes
/
main.go
File metadata and controls
25 lines (22 loc) · 805 Bytes
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
package main
import (
"fmt"
"net/http"
cfg "transfer-api-service/config"
"transfer-api-service/handler"
)
func main() {
// static
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static"))))
// interface
http.HandleFunc("/", handler.IndexHandler)
http.HandleFunc("/api/user/balance", handler.AuthInterceptor(handler.BalanceHandler))
http.HandleFunc("/api/user/transaction", handler.AuthInterceptor(handler.TransactionHandler))
http.HandleFunc("/api/user/transfer", handler.AuthInterceptor(handler.TransferHandler))
fmt.Printf("Service start,listening [%s]...\n", cfg.ServiceHost)
// Start Service
err := http.ListenAndServe(cfg.ServiceHost, nil)
if err != nil {
fmt.Printf("Failed to start service, err:%s", err.Error())
}
}