moved logger into middleware
This commit is contained in:
parent
e75468ce55
commit
a70d5a8548
2 changed files with 6 additions and 5 deletions
7
main.go
7
main.go
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/Bronku/iroon/auth"
|
"github.com/Bronku/iroon/auth"
|
||||||
|
"github.com/Bronku/iroon/middleware"
|
||||||
"github.com/Bronku/iroon/store"
|
"github.com/Bronku/iroon/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -27,8 +28,8 @@ func main() {
|
||||||
|
|
||||||
a = auth.New()
|
a = auth.New()
|
||||||
|
|
||||||
http.HandleFunc("GET /order/", logger(a.Authenticate(h.form)))
|
http.HandleFunc("GET /order/", middleware.Logger(a.Authenticate(h.form)))
|
||||||
http.HandleFunc("GET /", logger(a.Authenticate(h.index)))
|
http.HandleFunc("GET /", middleware.Logger(a.Authenticate(h.index)))
|
||||||
http.HandleFunc("POST /", logger(a.Authenticate(h.addOrder)))
|
http.HandleFunc("POST /", middleware.Logger(a.Authenticate(h.addOrder)))
|
||||||
http.ListenAndServe(":8080", nil)
|
http.ListenAndServe(":8080", nil)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package main
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func logger(in http.HandlerFunc) http.HandlerFunc {
|
func Logger(in http.HandlerFunc) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
//log := fmt.Sprint(r.Method, " ", r.URL.String())
|
//log := fmt.Sprint(r.Method, " ", r.URL.String())
|
||||||
Loading…
Add table
Add a link
Reference in a new issue