mirror of
https://github.com/cupcakearmy/codecrafters-http-server-go.git
synced 2024-11-09 18:34:18 +01: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 {
|
||||||
|
conn, err := l.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error accepting connection: ", err.Error())
|
fmt.Println("Error accepting connection: ", err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
go handleConnection(conn)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user