Commit 32417e13 by Ivana Huckova Committed by GitHub

Devenv: create slow_proxy_mac (#19174)

parent f7de64bd
FROM golang:latest
ADD main.go /
WORKDIR /
RUN go build -o main .
EXPOSE 3011
ENTRYPOINT ["/main"]
slow_proxy_mac:
build: docker/blocks/slow_proxy_mac
ports:
- '3011:3011'
environment:
ORIGIN_SERVER: 'http://host.docker.internal:9090/'
package main
import (
"fmt"
"log"
"net/http"
"net/http/httputil"
"net/url"
"os"
"time"
)
func main() {
origin := os.Getenv("ORIGIN_SERVER")
if origin == "" {
origin = "http://host.docker.internal:9090/"
}
sleep := time.Minute
originURL, _ := url.Parse(origin)
proxy := httputil.NewSingleHostReverseProxy(originURL)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Printf("sleeping for %s then proxying request: %s", sleep.String(), r.RequestURI)
<-time.After(sleep)
proxy.ServeHTTP(w, r)
})
log.Fatal(http.ListenAndServe(":3011", nil))
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment