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