Explorar o código

Добавить 'dock'

Gr794_Vaa %!s(int64=2) %!d(string=hai) anos
pai
achega
fc7ba7b9c6
Modificáronse 1 ficheiros con 61 adicións e 0 borrados
  1. 61 0
      dock

+ 61 - 0
dock

@@ -0,0 +1,61 @@
+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)
+}