add basic auth for webapi

This commit is contained in:
ginuerzh
2022-02-12 21:05:39 +08:00
parent fdd67a6086
commit f2d806886a
12 changed files with 197 additions and 86 deletions

View File

@ -10,6 +10,12 @@ import (
"github.com/go-gost/gost/pkg/logger"
)
type Servicer interface {
Serve() error
Addr() net.Addr
Close() error
}
type Service struct {
listener listener.Listener
handler handler.Handler
@ -35,15 +41,11 @@ func (s *Service) Addr() net.Addr {
return s.listener.Addr()
}
func (s *Service) Run() error {
return s.serve()
}
func (s *Service) Close() error {
return s.listener.Close()
}
func (s *Service) serve() error {
func (s *Service) Serve() error {
var tempDelay time.Duration
for {
conn, e := s.listener.Accept()