This commit is contained in:
lbenedar
2026-02-23 15:00:41 +03:00
parent b1935a4057
commit 1f4ba997b7
6 changed files with 169 additions and 0 deletions

28
ch13/1/ch13_1.go Normal file
View File

@@ -0,0 +1,28 @@
package main
import (
"net/http"
"time"
)
type TimeHandler struct{}
func (th TimeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(time.Now().Format(time.RFC3339)))
}
func main() {
server := http.Server{
Addr: ":10100",
ReadTimeout: 30 * time.Second,
WriteTimeout: 90 * time.Second,
IdleTimeout: 120 * time.Second,
Handler: TimeHandler{},
}
err := server.ListenAndServe()
if err != nil {
if err != http.ErrServerClosed {
panic(err)
}
}
}

3
ch13/1/go.mod Normal file
View File

@@ -0,0 +1,3 @@
module gitea.local.lab/Lbenedar/learning_go/ch13/1
go 1.25.0