aboutsummaryrefslogtreecommitdiff
path: root/backend/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'backend/main.go')
-rw-r--r--backend/main.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/backend/main.go b/backend/main.go
new file mode 100644
index 0000000..f5c754c
--- /dev/null
+++ b/backend/main.go
@@ -0,0 +1,29 @@
+package main
+
+import (
+ "fmt"
+ "io"
+ "net/http"
+)
+
+func helloHandler(w http.ResponseWriter, _ *http.Request) {
+ w.Write([]byte("Hello, World!"))
+}
+
+func requestServer() {
+ resp, err := http.Get("http://localhost:8080")
+ fmt.Println(err)
+ defer resp.Body.Close()
+ body, err := io.ReadAll(resp.Body)
+ fmt.Printf("\nWebserver said: `%s`", string(body))
+}
+
+func main() {
+ http.HandleFunc("/", helloHandler)
+ go func() {
+ err := http.ListenAndServe(":8080", nil)
+ fmt.Println(err) // don't ignore errors
+ }()
+
+ requestServer()
+}