123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package main
- import (
- "fmt"
- "log"
- "net/http"
- "strings"
- "time"
- )
- func main() {
- http.HandleFunc("/", slash)
- http.HandleFunc("/ok", ok)
- http.HandleFunc("/info", info)
- http.HandleFunc("/status", status)
- err := http.ListenAndServe("localhost:0808", nil)
- if err != nil {
- log.Fatal("ListenAndServe: ", err)
- }
- }
- func slash (w http.ResponseWriter,r *http.Request) {
- fmt.Fprint(w,"it alive")
- }
- func ok (w http.ResponseWriter,r *http.Request) {
- w.WriteHeader(http.StatusOK)
- fmt.Fprint(w,"http status ok ")
- }
- func info (w http.ResponseWriter,r *http.Request) {
- fmt.Fprint(w,"LI Vladislave♂")
- }
- func status (w http.ResponseWriter,r *http.Request) {
- var remoteIp = r.RemoteAddr
- var splitIp = strings.Split(remoteIp, ".")
- var fmtIP = fmt.Sprint(splitIp[0], ".x./.", strings.Split(splitIp[3], ":")[0])
- var fmtDate = time.Now().Format("2006-01-02 3:4:5 ")
- fmt.Fprintf(w,"made the Vlad\n")
- fmt.Fprintf(w, fmtDate + "\n")
- fmt.Fprintf(w, fmtIP)
- }
|