Skip to content

Instantly share code, notes, and snippets.

@fourswordsio
Created December 8, 2019 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fourswordsio/cc7571af1090285d8064c7a403b7c228 to your computer and use it in GitHub Desktop.
Save fourswordsio/cc7571af1090285d8064c7a403b7c228 to your computer and use it in GitHub Desktop.
package main
import (
"github.com/linkpoolio/bridges"
"net/http"
)
type GasStation struct{}
// Run implements Bridge Run for querying the ETH Gas Station
func (gs *GasStation) Run(h *bridges.Helper) (interface{}, error) {
obj := make(map[string]interface{})
err := h.HTTPCall(
http.MethodGet,
"https://ethgasstation.info/json/ethgasAPI.json",
&obj,
)
return obj["average"], err
}
// Opts is the bridge.Bridge implementation
func (gs *GasStation) Opts() *bridges.Opts {
return &bridges.Opts{
Name: "GasStation",
Lambda: true,
}
}
func Handler(w http.ResponseWriter, r *http.Request) {
bridges.NewServer(&GasStation{}).Handler(w, r)
}
func main() {
bridges.NewServer(&GasStation{}).Start(8080)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment