add ch13
This commit is contained in:
28
ch13/1/ch13_1.go
Normal file
28
ch13/1/ch13_1.go
Normal 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
3
ch13/1/go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module gitea.local.lab/Lbenedar/learning_go/ch13/1
|
||||
|
||||
go 1.25.0
|
||||
Reference in New Issue
Block a user