-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (28 loc) · 795 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"fmt"
"os"
api "primitivo.fr/applinh/GoFire/apihandler"
"log"
"net/http"
"github.com/gorilla/mux"
)
func Rewriter(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.RequestURI)
})
}
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "5000"
}
r := mux.NewRouter()
r.HandleFunc("/", api.HomeHandler).Methods("GET")
r.HandleFunc("/{res}", api.GET_ResHandler).Methods("GET")
r.HandleFunc("/{res}/{id}", api.GET_ResHandler).Methods("GET")
r.HandleFunc("/{res}", api.POST_ResHandler).Methods("POST")
r.HandleFunc("/{res}/{id}", api.PATCH_ResHandler).Methods("PATCH")
log.Println("Starting FireGo on port " + port)
log.Fatal(http.ListenAndServe("0.0.0.0:"+port, r))
}