-
Notifications
You must be signed in to change notification settings - Fork 15
/
init_service.go
29 lines (24 loc) 路 1.28 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
27
28
29
package app
import (
"context"
"net/http"
"time"
"github.com/number571/go-peer/cmd/hidden_lake/service/internal/handler"
hls_settings "github.com/number571/go-peer/cmd/hidden_lake/service/pkg/settings"
)
func (p *sApp) initServiceHTTP(pCtx context.Context) {
mux := http.NewServeMux()
cfg := p.fCfgW.GetConfig()
mux.HandleFunc(hls_settings.CHandleIndexPath, handler.HandleIndexAPI(p.fHTTPLogger))
mux.HandleFunc(hls_settings.CHandleConfigSettingsPath, handler.HandleConfigSettingsAPI(p.fCfgW, p.fHTTPLogger, p.fNode))
mux.HandleFunc(hls_settings.CHandleConfigConnectsPath, handler.HandleConfigConnectsAPI(pCtx, p.fCfgW, p.fHTTPLogger, p.fNode))
mux.HandleFunc(hls_settings.CHandleConfigFriendsPath, handler.HandleConfigFriendsAPI(p.fCfgW, p.fHTTPLogger, p.fNode))
mux.HandleFunc(hls_settings.CHandleNetworkOnlinePath, handler.HandleNetworkOnlineAPI(p.fHTTPLogger, p.fNode))
mux.HandleFunc(hls_settings.CHandleNetworkRequestPath, handler.HandleNetworkRequestAPI(pCtx, cfg, p.fHTTPLogger, p.fNode))
mux.HandleFunc(hls_settings.CHandleNetworkPubKeyPath, handler.HandleNetworkPubKeyAPI(p.fHTTPLogger, p.fNode))
p.fServiceHTTP = &http.Server{
Addr: cfg.GetAddress().GetHTTP(),
ReadTimeout: (5 * time.Second),
Handler: http.TimeoutHandler(mux, (10 * time.Minute), "timeout"),
}
}