add content type

This commit is contained in:
Niccolo Borgioli 2024-05-25 00:25:07 +02:00
parent 77e886b8f9
commit 87aa98c68e
No known key found for this signature in database
GPG Key ID: 4897ACD13A65977C

View File

@ -113,7 +113,12 @@ func handleConnection(conn net.Conn) {
re := regexp.MustCompile(`^/echo/([A-Za-z]+)$`) re := regexp.MustCompile(`^/echo/([A-Za-z]+)$`)
matches := re.FindStringSubmatch(request.Path) matches := re.FindStringSubmatch(request.Path)
if len(matches) > 0 { if len(matches) > 0 {
Respond(conn, Response{Version: request.Version, Code: OK, Body: matches[1]}) Respond(conn, Response{
Version: request.Version,
Code: OK,
Body: matches[1],
Headers: []Header{Header{Name: "Content-Type", Value: "text/plain"}},
})
return return
} }