fix auth for file handler

This commit is contained in:
ginuerzh
2023-12-16 14:28:58 +08:00
parent b1390dda1c
commit f847fa533e
17 changed files with 263 additions and 201 deletions

View File

@ -33,8 +33,9 @@ func AutherOption(auther auth.Authenticator) Option {
}
type metricService struct {
s *http.Server
ln net.Listener
s *http.Server
ln net.Listener
cclose chan struct{}
}
func NewService(addr string, opts ...Option) (service.Service, error) {
@ -66,7 +67,8 @@ func NewService(addr string, opts ...Option) (service.Service, error) {
s: &http.Server{
Handler: mux,
},
ln: ln,
ln: ln,
cclose: make(chan struct{}),
}, nil
}
@ -81,3 +83,12 @@ func (s *metricService) Addr() net.Addr {
func (s *metricService) Close() error {
return s.s.Close()
}
func (s *metricService) IsClosed() bool {
select {
case <-s.cclose:
return true
default:
return false
}
}