chore: initial commit
This commit is contained in:
30
internal/handler/web.go
Normal file
30
internal/handler/web.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"server/internal/pkg/httputil"
|
||||
"server/internal/utils"
|
||||
)
|
||||
|
||||
type WebHandler struct {
|
||||
}
|
||||
|
||||
func NewWebHandler() *WebHandler {
|
||||
return &WebHandler{}
|
||||
}
|
||||
|
||||
func (h *WebHandler) GetClientInfo(w http.ResponseWriter, r *http.Request) {
|
||||
ip := utils.ClientIP(r)
|
||||
userAgent := r.UserAgent()
|
||||
|
||||
httputil.Ok(w, map[string]any{
|
||||
"ip": ip,
|
||||
"userAgent": userAgent,
|
||||
"method": r.Method,
|
||||
"host": r.Host,
|
||||
"path": r.URL.Path,
|
||||
"origin": r.Header.Get("Origin"),
|
||||
"accept": r.Header.Get("Accept"),
|
||||
"acceptLanguage": r.Header.Get("Accept-Language"),
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user