mirror of
https://github.com/cupcakearmy/codecrafters-http-server-go.git
synced 2024-12-21 23:56:30 +00:00
first solution
This commit is contained in:
parent
36ab88d947
commit
71fec75973
@ -7,6 +7,10 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
func handleConnection(conn net.Conn) {
|
||||
fmt.Fprintf(conn, "HTTP/1.1 200 OK\r\n\r\n")
|
||||
}
|
||||
|
||||
func main() {
|
||||
// You can use print statements as follows for debugging, they'll be visible when running tests.
|
||||
fmt.Println("Logs from your program will appear here!")
|
||||
@ -19,9 +23,13 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
_, err = l.Accept()
|
||||
if err != nil {
|
||||
fmt.Println("Error accepting connection: ", err.Error())
|
||||
os.Exit(1)
|
||||
for {
|
||||
conn, err := l.Accept()
|
||||
if err != nil {
|
||||
fmt.Println("Error accepting connection: ", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
go handleConnection(conn)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user