-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.go
37 lines (29 loc) · 891 Bytes
/
app.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
package main
import (
"github.com/ahaha0807/yorozuya-serverside/handler"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"log"
"net/http"
)
type Config struct {
Addr string
Port string
}
func main() {
config := Config{
Addr: "127.0.0.1",
Port: ":9999",
}
router := mux.NewRouter()
// routing
router.HandleFunc("/", handler.HomeHandler).Methods("GET")
router.HandleFunc("/ranking", handler.RankingPageHandler).Methods("GET")
router.HandleFunc("/api/price", handler.ZaifHandler).Methods("GET")
router.HandleFunc("/api/ranking", handler.RankingHandler).Methods("GET")
// static files settings
router.PathPrefix("/").Handler(http.StripPrefix("/public/", http.FileServer(http.Dir("./public/"))))
http.Handle("/", router)
log.Println("Server is Running on " + config.Addr + config.Port)
log.Fatal(http.ListenAndServe(config.Port, handlers.CORS()(router)))
}