diff --git a/server.go b/server.go index 45be448..f441da4 100644 --- a/server.go +++ b/server.go @@ -53,6 +53,8 @@ func NewRelayServer(cfg Config) (http.Handler, error) { } func (s *RelayServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { + s.printRequest(r) + switch r.URL.Path { case "", "/": uid, err := s.readUserID(r) @@ -74,6 +76,21 @@ func (s *RelayServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { } } +func (s *RelayServer) printRequest(r *http.Request) { + log.Println("--- request start ---") + log.Println("path:") + log.Println(r.URL) + log.Println("headers:") + for k := range r.Header { + log.Println(k, "=", r.Header.Get(k)) + } + log.Println("cookies:") + for _, c := range r.Cookies() { + log.Println(c.String()) + } + log.Println("--- request end ---") +} + func (s *RelayServer) redirect(w http.ResponseWriter, loc string) { nr, err := http.NewRequest(http.MethodGet, loc, nil) if err != nil {