MCPcopy Create free account
hub / github.com/ebosas/microservices / main

Function main

cmd/server/server.go:33–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31)
32
33func main() {
34 fmt.Println("[Server]")
35
36 // Establish a Rabbit connection.
37 connMQ, err := rabbit.GetConn(conf.RabbitURL)
38 if err != nil {
39 log.Fatalf("rabbit connection: %s", err)
40 }
41 defer connMQ.Close()
42
43 err = connMQ.DeclareTopicExchange(conf.Exchange)
44 if err != nil {
45 log.Fatalf("declare exchange: %s", err)
46 }
47
48 // Redis connection
49 connR := redis.NewClient(&redis.Options{
50 Addr: conf.RedisURL,
51 Password: "", // no password set
52 DB: 0, // use default DB
53 })
54
55 http.Handle("/static/", http.FileServer(http.FS(filesStatic)))
56 http.HandleFunc("/", handleHome)
57 http.HandleFunc("/messages", handleMessages(connR))
58 http.HandleFunc("/ws", handleWebsocketConn(connMQ))
59 http.HandleFunc("/api/cache", handleAPICache(connR)) // defined in api.go
60 log.Fatal(http.ListenAndServe(conf.ServerAddr, nil))
61}
62
63// handleHome handles the home page.
64func handleHome(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 6

GetConnFunction · 0.92
handleMessagesFunction · 0.85
handleWebsocketConnFunction · 0.85
handleAPICacheFunction · 0.85
CloseMethod · 0.80
DeclareTopicExchangeMethod · 0.80

Tested by

no test coverage detected