30 lines
618 B
Go
30 lines
618 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"log"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
type Response struct {
|
||
|
Message string `json:"message"`
|
||
|
Headers map[string][]string `json:"headers"`
|
||
|
Path string `json:"path"`
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||
|
response := Response{
|
||
|
Message: "Hello from backend server!",
|
||
|
Headers: r.Header,
|
||
|
Path: r.URL.Path,
|
||
|
}
|
||
|
|
||
|
w.Header().Set("Content-Type", "application/json")
|
||
|
json.NewEncoder(w).Encode(response)
|
||
|
})
|
||
|
|
||
|
log.Println("Backend server démarré sur :8080")
|
||
|
log.Fatal(http.ListenAndServe(":8080", nil))
|
||
|
}
|