12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- FROM golang:onbuild
- WORKDIR ./main
- COPY ./ ./
- RUN go build -o DockerFile .
- EXPOSE 7070
- ENTRYPOINT ["./main.go"]
- package main
- import (
- "log"
- "io/ioutil"
- "net/http"
- "fmt"
- "regexp"
- "time"
- )
- func main() {
- gugugaga()
- }
- func gugugaga() {
- http.HandleFunc("/ok/", status200)
- http.HandleFunc("/info/", information)
- http.HandleFunc("/status/", status)
- http.HandleFunc("/test1/", test1)
- err := http.ListenAndServe(":7070", nil)
- if err != nil {
- log.Fatal("ListenAndServer:", err)
- return
- }
- }
- func status200(w http.ResponseWriter, r *http.Request) {
- w.Write([]byte("статус 200"))
- }
- func information(w http.ResponseWriter, r *http.Request) {
- w.Write([]byte("группа 792(4)\n Варламов Алексей"))
- }
- func status(w http.ResponseWriter, r *http.Request){
- res,_:= http.Get("https://api.ipify.org/")
- ip, err:=ioutil.ReadAll(res.Body)
- if err != nil {
- return
- }
- fmt.Fprintf(w, "%s\n", ip)
- today := time.Now()
- fmt.Fprintf(w, today.Format("2006-01-02 3:4:5 pm"))
- reg := regexp.MustCompile("[.].+[.]")
- out := string(ip)
- ewq := reg.ReplaceAllString(out, ".o.o.")
- fmt.Fprintf(w, "\n%s",ewq)
- }
|