MCPcopy Create free account
hub / github.com/DoNewsCode/core / ProvideHTTP

Method ProvideHTTP

leader/example_server_test.go:22–30  ·  view source on GitHub ↗
(router *mux.Router)

Source from the content-addressed store, hash-verified

20}
21
22func (s ServerModule) ProvideHTTP(router *mux.Router) {
23 router.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
24 if s.Sts.IsLeader() {
25 writer.Write([]byte("I am leader"))
26 } else {
27 writer.Write([]byte("I am follower"))
28 }
29 })
30}
31
32func Example_server() {
33 if os.Getenv("ETCD_ADDR") == "" {

Callers

nothing calls this directly

Calls 2

IsLeaderMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected