fix
This commit is contained in:
parent
43e476d897
commit
19aff26259
17
main.go
17
main.go
@ -1,15 +1,26 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"queues-go/app/routers"
|
"queues-go/app/routers"
|
||||||
client "queues-go/app/storage/mongo"
|
client "queues-go/app/storage/mongo"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func handlerWrapper(f func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request) {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
start := time.Now()
|
||||||
|
f(w, r)
|
||||||
|
log.Printf("%s %s", r.URL, time.Since(start))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
client.Connect()
|
client.Connect()
|
||||||
http.HandleFunc("/api/v1/take", routers.Take)
|
http.HandleFunc("/api/v1/take", handlerWrapper(routers.Take))
|
||||||
http.HandleFunc("/api/v1/finish", routers.Finish)
|
http.HandleFunc("/api/v1/finish", handlerWrapper(routers.Finish))
|
||||||
http.HandleFunc("/api/v1/put", routers.Put)
|
http.HandleFunc("/api/v1/put", handlerWrapper(routers.Put))
|
||||||
|
log.Printf("Server started")
|
||||||
http.ListenAndServe(":1239", nil)
|
http.ListenAndServe(":1239", nil)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user