mirror of https://github.com/0xERR0R/blocky.git
refactor(service): make `Info` fields private
This commit is contained in:
parent
48cad3b786
commit
74b8931998
|
@ -21,7 +21,7 @@ func NewService(cfg config.APIService, server StrictServerInterface) *Service {
|
|||
SimpleHTTP: service.NewSimpleHTTP("API", endpoints),
|
||||
}
|
||||
|
||||
registerOpenAPIEndpoints(s.Mux, server)
|
||||
registerOpenAPIEndpoints(s.Router(), server)
|
||||
|
||||
return s
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ func NewService(cfg config.MetricsService, metricsCfg config.Metrics) *Service {
|
|||
SimpleHTTP: service.NewSimpleHTTP("Metrics", endpoints),
|
||||
}
|
||||
|
||||
s.Mux.Handle(
|
||||
s.Router().Handle(
|
||||
metricsCfg.Path,
|
||||
promhttp.InstrumentMetricHandler(reg, promhttp.HandlerFor(reg, promhttp.HandlerOpts{})),
|
||||
)
|
||||
|
|
|
@ -30,7 +30,7 @@ func newDoHService(cfg config.DoHService, handler dnsHandler) *dohService {
|
|||
handler: handler,
|
||||
}
|
||||
|
||||
s.Mux.Route("/dns-query", func(mux chi.Router) {
|
||||
s.Router().Route("/dns-query", func(mux chi.Router) {
|
||||
// Handlers for / also handle /dns-query without trailing slash
|
||||
|
||||
mux.Get("/", s.handleGET)
|
||||
|
|
|
@ -27,18 +27,18 @@ type HTTPService interface {
|
|||
type HTTPInfo struct {
|
||||
Info
|
||||
|
||||
Mux *chi.Mux
|
||||
mux *chi.Mux
|
||||
}
|
||||
|
||||
func NewHTTPInfo(name string, endpoints []Endpoint) HTTPInfo {
|
||||
return HTTPInfo{
|
||||
Info: NewInfo(name, endpoints),
|
||||
|
||||
Mux: chi.NewMux(),
|
||||
mux: chi.NewMux(),
|
||||
}
|
||||
}
|
||||
|
||||
func (i *HTTPInfo) Router() chi.Router { return i.Mux }
|
||||
func (i *HTTPInfo) Router() chi.Router { return i.mux }
|
||||
|
||||
var _ HTTPService = (*SimpleHTTP)(nil)
|
||||
|
||||
|
|
|
@ -45,19 +45,19 @@ func svcString(s Service) string {
|
|||
|
||||
// Info can be embedded in structs to help implement Service.
|
||||
type Info struct {
|
||||
Name string
|
||||
Endpoints []Endpoint
|
||||
name string
|
||||
endpoints []Endpoint
|
||||
}
|
||||
|
||||
func NewInfo(name string, endpoints []Endpoint) Info {
|
||||
return Info{
|
||||
Name: name,
|
||||
Endpoints: endpoints,
|
||||
name: name,
|
||||
endpoints: endpoints,
|
||||
}
|
||||
}
|
||||
|
||||
func (i *Info) ServiceName() string { return i.Name }
|
||||
func (i *Info) ExposeOn() []Endpoint { return i.Endpoints }
|
||||
func (i *Info) ServiceName() string { return i.name }
|
||||
func (i *Info) ExposeOn() []Endpoint { return i.endpoints }
|
||||
func (i *Info) String() string { return svcString(i) }
|
||||
|
||||
// GroupByListener returns a map of listener and services grouped by configured address.
|
||||
|
|
Loading…
Reference in New Issue