prysm-pulse/tools/contract-addr/main.go
Preston Van Loon c9ca5857f8
Avoid automaxprocs default logger to printf (#6524)
* Avoid automaxprocs default logger to printf
* Merge branch 'master' into maxprocs
* gofmt, goimports
* Merge refs/heads/master into maxprocs
* Merge refs/heads/master into maxprocs
* gazelle for docker images
* Merge refs/heads/master into maxprocs
* Merge refs/heads/master into maxprocs
* Merge refs/heads/master into maxprocs
* Merge refs/heads/master into maxprocs
* Merge refs/heads/master into maxprocs
* Merge refs/heads/master into maxprocs
* Merge refs/heads/master into maxprocs
* Merge refs/heads/master into maxprocs
* Merge refs/heads/master into maxprocs
* Merge refs/heads/master into maxprocs
* Merge refs/heads/master into maxprocs
* Merge refs/heads/master into maxprocs
* Merge refs/heads/master into maxprocs
* fix docker
* Merge refs/heads/master into maxprocs
* Merge refs/heads/master into maxprocs
2020-07-11 00:57:43 +00:00

45 lines
936 B
Go

/**
* This tool exists to serve currently configured contract address in k8s.
* It reads the contract address from a plain text file as provided by etcd.
*/
package main
import (
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
_ "github.com/prysmaticlabs/prysm/shared/maxprocs"
)
var address = flag.String("address-path", "", "The file path to the plain text file with the contract address")
func main() {
flag.Parse()
if *address == "" {
panic("Contract address filepath not set")
}
fmt.Println("Starting on port 8080")
log.Fatal(http.ListenAndServe(":8080", &handler{}))
}
type handler struct{}
func (h *handler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
dat, err := ioutil.ReadFile(*address)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
_, err = io.WriteString(w, string(dat))
if err != nil {
fmt.Printf("Failed to write response: %v", err)
}
}