Skip to content

Commit

Permalink
refactor(service): make Info fields private
Browse files Browse the repository at this point in the history
  • Loading branch information
ThinkChaos committed Apr 3, 2024
1 parent cd7e18f commit 9096e47
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func NewService(cfg config.APIService, server StrictServerInterface) *Service {
SimpleHTTP: service.NewSimpleHTTP("API", endpoints),
}

registerOpenAPIEndpoints(s.Mux, server)
registerOpenAPIEndpoints(s.Router(), server)

return s
}
2 changes: 1 addition & 1 deletion metrics/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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{})),
)
Expand Down
2 changes: 1 addition & 1 deletion server/doh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions service/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 6 additions & 6 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 9096e47

Please sign in to comment.