|
@@ -3,12 +3,17 @@ package main
|
|
|
import (
|
|
|
"fmt"
|
|
|
"log"
|
|
|
+ "net"
|
|
|
"net/http"
|
|
|
+ "regexp"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
func main() {
|
|
|
+ http.Handle("/", http.FileServer(http.Dir("./static")))
|
|
|
http.HandleFunc("/ok", sayhello)
|
|
|
http.HandleFunc("/info", sayhello1)
|
|
|
+ http.HandleFunc("/status", status)
|
|
|
err := http.ListenAndServe(":8080", nil)
|
|
|
if err != nil {
|
|
|
log.Fatal("ListenAndServe: ", err)
|
|
@@ -19,5 +24,14 @@ func sayhello(w http.ResponseWriter, r *http.Request) {
|
|
|
w.WriteHeader(200)
|
|
|
}
|
|
|
func sayhello1(w http.ResponseWriter, r *http.Request) {
|
|
|
- fmt.Fprintf(w, "Незговоров Н.В. 792")
|
|
|
+ fmt.Fprintf(w, "Незговоров Н.В.")
|
|
|
+}
|
|
|
+
|
|
|
+func status(w http.ResponseWriter, r *http.Request) {
|
|
|
+ time := time.Now()
|
|
|
+ ip, _, _ := net.SplitHostPort(r.RemoteAddr)
|
|
|
+ re := regexp.MustCompile(`[.].*[.]`)
|
|
|
+ fmt.Fprintln(w, re.ReplaceAllString(ip, ".*.*."))
|
|
|
+ fmt.Fprintf(w, "Незговоров Н.В."+"\n")
|
|
|
+ fmt.Fprintln(w, time.Format("2006-01-02 3:4:5 pm"))
|
|
|
}
|