forked from bottlesdevs/steamgrid-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
25 lines (19 loc) · 782 Bytes
/
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
package main
import (
"net/http"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"usebottles.com/steamgrid-proxy/config"
"usebottles.com/steamgrid-proxy/controller"
)
func main() {
cnf := *config.Cnf
router := mux.NewRouter()
apiRouter := router.PathPrefix("/api").Subrouter()
apiRouter.HandleFunc("/search/{gameName}", controller.Search).Methods("GET")
apiRouter.HandleFunc("/search/{gameName}/{type}", controller.Search).Methods("GET")
headersOk := handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization"})
originsOk := handlers.AllowedOrigins([]string{"*"})
methodsOk := handlers.AllowedMethods([]string{"GET", "HEAD", "OPTIONS"})
http.ListenAndServe(":"+cnf.Port, handlers.CORS(originsOk, headersOk, methodsOk)(router))
}