blob: 991797d4da8cc76a862679cae6e94f71d9bd0047 [file] [log] [blame]
Serge Bazanski8d7843c2018-10-04 10:37:36 +01001package main
2
Serge Bazanski46765082018-10-06 12:32:01 +01003import (
4 "net/http"
Serge Bazanski8d7843c2018-10-04 10:37:36 +01005
Serge Bazanski46765082018-10-06 12:32:01 +01006 "code.hackerspace.pl/q3k/topo/graph"
7 "github.com/golang/glog"
8 _ "github.com/q3k/statusz"
9)
10
11type ServiceConfig struct {
12 DebugListen string
13}
14
15type Service struct {
16 gr *graph.Graph
17 config ServiceConfig
18}
19
20func NewService(gr *graph.Graph, c ServiceConfig) *Service {
21 return &Service{
22 gr: gr,
23 config: c,
24 }
25}
26
27func (s *Service) Run() {
28 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
29 http.Redirect(w, r, "/debug/status", http.StatusSeeOther)
30 })
31 glog.Infof("Debug listening on %s....", s.config.DebugListen)
32 http.ListenAndServe(s.config.DebugListen, nil)
Serge Bazanski8d7843c2018-10-04 10:37:36 +010033}