mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 02:40:26 -06:00
b426ff5292
this can be useful when testing timeouts etc in the dataproxy ref #16923
32 lines
580 B
Go
32 lines
580 B
Go
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://localhost: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))
|
|
}
|