MCPcopy Create free account
hub / github.com/devfullcycle/goexpert / handler

Function handler

5-Context/2-Client-Server/server/main.go:14–28  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

12}
13
14func handler(w http.ResponseWriter, r *http.Request) {
15 ctx := r.Context()
16 log.Println("Request iniciada")
17 defer log.Println("Request finalizada")
18 select {
19 case <-time.After(5 * time.Second):
20 // Imprime no comand line stdout
21 log.Println("Request processada com sucesso")
22 // Imprime no browser
23 w.Write([]byte("Request processada com sucesso"))
24 case <-ctx.Done():
25 // Imprime no comand line stdout
26 log.Println("Request cancelada pelo cliente")
27 }
28}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected