summaryrefslogtreecommitdiff
path: root/internal/server/router.go
blob: ed33c19af5178fc9ac0240f502cb1da473b2fa51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package server

import (
	"fmt"
	"net/http"
	"time"
)

func (srv *server) ListenToRequests() {
	h := srv.actions
	mux := http.NewServeMux()
	server := &http.Server{
		Addr:         "localhost:9000",
		Handler:      mux,
		ReadTimeout:  time.Second * 5,
		WriteTimeout: time.Second * 5,
	}

	mux.HandleFunc("/ping", h.Ping)

	fmt.Printf("Listening on %v\n", server.Addr)
	server.ListenAndServe()
}