Dashboard server draft
This commit is contained in:
parent
80da11ad60
commit
7af5b18d85
|
@ -0,0 +1,27 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
port int
|
||||
mux *http.ServeMux
|
||||
}
|
||||
|
||||
func NewServer(port int) *Server {
|
||||
return &Server{
|
||||
port: port,
|
||||
mux: http.NewServeMux(),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) Handle(pattern string, handler http.Handler) {
|
||||
s.mux.Handle(pattern, handler)
|
||||
}
|
||||
|
||||
func (s *Server) Start() {
|
||||
addr := fmt.Sprintf(":%d", port)
|
||||
go http.ListenAndServe(addr, s.mux)
|
||||
}
|
Loading…
Reference in New Issue