1
0
Fork 0
shezmu/server/server.go

28 lines
401 B
Go
Raw Normal View History

2015-10-27 01:22:45 +00:00
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)
}