Added IP and Browser string to submit routines
This commit is contained in:
parent
fefd6dbdce
commit
4d3a84b6b3
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net"
|
||||||
"qurl/qurl"
|
"qurl/qurl"
|
||||||
"qurl/static"
|
"qurl/static"
|
||||||
"qurl/storage"
|
"qurl/storage"
|
||||||
@ -53,6 +54,12 @@ func (ctx *SubmitHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
URL: u,
|
URL: u,
|
||||||
Created: time.Now(),
|
Created: time.Now(),
|
||||||
}
|
}
|
||||||
|
if h, _, err := net.SplitHostPort(r.RemoteAddr); err == nil && h != "" {
|
||||||
|
q.IP = net.ParseIP(h)
|
||||||
|
}
|
||||||
|
if b := r.Header.Get("User-Agent"); b != "" {
|
||||||
|
q.Browser = b
|
||||||
|
}
|
||||||
|
|
||||||
err := q.CheckValid()
|
err := q.CheckValid()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user