-
Notifications
You must be signed in to change notification settings - Fork 15
/
init_service.go
26 lines (21 loc) 路 1.04 KB
/
init_service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package app
import (
"context"
"net/http"
"time"
"github.com/number571/go-peer/cmd/hidden_lake/helpers/traffic/internal/handler"
pkg_settings "github.com/number571/go-peer/cmd/hidden_lake/helpers/traffic/pkg/settings"
)
func (p *sApp) initServiceHTTP(pCtx context.Context) {
mux := http.NewServeMux()
mux.HandleFunc(pkg_settings.CHandleIndexPath, handler.HandleIndexAPI(p.fHTTPLogger))
mux.HandleFunc(pkg_settings.CHandleStoragePointerPath, handler.HandlePointerAPI(p.fDatabase, p.fHTTPLogger))
mux.HandleFunc(pkg_settings.CHandleStorageHashesPath, handler.HandleHashesAPI(p.fDatabase, p.fHTTPLogger))
mux.HandleFunc(pkg_settings.CHandleNetworkMessagePath, handler.HandleMessageAPI(pCtx, p.fConfig, p.fDatabase, p.fHTTPLogger, p.fAnonLogger, p.fNode))
mux.HandleFunc(pkg_settings.CHandleConfigSettings, handler.HandleConfigSettingsAPI(p.fConfig, p.fHTTPLogger))
p.fServiceHTTP = &http.Server{
Addr: p.fConfig.GetAddress().GetHTTP(),
ReadTimeout: (5 * time.Second),
Handler: http.TimeoutHandler(mux, time.Minute/2, "timeout"),
}
}