You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
635 B
32 lines
635 B
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
type HelloWorldHandler struct {
|
|
}
|
|
|
|
func (h *HelloWorldHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
w.WriteHeader(http.StatusOK)
|
|
w.Write([]byte("Hello, World!"))
|
|
}
|
|
|
|
func main() {
|
|
h := &HelloWorldHandler{}
|
|
|
|
s := &http.Server{
|
|
Addr: ":8001",
|
|
Handler: h,
|
|
ReadTimeout: 10 * time.Second,
|
|
ReadHeaderTimeout: 10 * time.Second,
|
|
WriteTimeout: 10 * time.Second,
|
|
MaxHeaderBytes: 1 << 20,
|
|
IdleTimeout: 10 * time.Second,
|
|
}
|
|
fmt.Println("Listening for requests on port 8001...")
|
|
log.Fatal(s.ListenAndServe())
|
|
}
|
|
|