about summary refs log tree commit diff
path: root/src/rest-api/cmd/main.go
blob: 56cc6a34d47b8ca7129223e5f4612f13652b5185 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	http.HandleFunc("/", handleRequest)

	http.ListenAndServe(":8080", nil)
}

func handleRequest(w http.ResponseWriter, r *http.Request) {
	bytes, err := io.ReadAll(io.Reader(r.Body))
	if err != nil {
		panic(err)
	}

	fmt.Fprint(w, "Hello, World!", string(bytes))
}