mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Devenv: create slow_proxy_mac (#19174)
This commit is contained in:
parent
f7de64bd15
commit
32417e1388
7
devenv/docker/blocks/slow_proxy_mac/Dockerfile
Normal file
7
devenv/docker/blocks/slow_proxy_mac/Dockerfile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
FROM golang:latest
|
||||||
|
ADD main.go /
|
||||||
|
WORKDIR /
|
||||||
|
RUN go build -o main .
|
||||||
|
EXPOSE 3011
|
||||||
|
ENTRYPOINT ["/main"]
|
6
devenv/docker/blocks/slow_proxy_mac/docker-compose.yaml
Normal file
6
devenv/docker/blocks/slow_proxy_mac/docker-compose.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
slow_proxy_mac:
|
||||||
|
build: docker/blocks/slow_proxy_mac
|
||||||
|
ports:
|
||||||
|
- '3011:3011'
|
||||||
|
environment:
|
||||||
|
ORIGIN_SERVER: 'http://host.docker.internal:9090/'
|
31
devenv/docker/blocks/slow_proxy_mac/main.go
Normal file
31
devenv/docker/blocks/slow_proxy_mac/main.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
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))
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user