Initial upload to github

This commit is contained in:
Calamitas 2022-07-12 23:05:53 -05:00
parent 5aeddbc8c1
commit e90e769fa5

25
server.go Normal file
View File

@ -0,0 +1,25 @@
package main
import (
"fmt"
"log"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
ip := getIP(w, r)
fmt.Fprintf(w, ip)
}
func getIP(w http.ResponseWriter, r *http.Request) string {
IP := r.Header.Get("X-REAL-IP")
if IP != "" {
return IP
} else {
return "No IPV4"
}
}
func main() {
http.HandleFunc("/", handler)
log.Fatal(http.ListenAndServe(":8081", nil))
}