Split Dispatcher interface and use it across application

This commit is contained in:
ErickSkrauch committed 2020-04-20 14:29:33 +03:00
1 parent f58b980948
commit 2ea4c55d37
5 files changed
+22 -27

No files matched your search

+3 -20
View File
@@ -3,37 +3,20 @@ package http
import (
"context"
"encoding/json"
"net"
"net/http"
"os"
"os/signal"
"strings"
"time"
"github.com/gorilla/mux"
"github.com/mono83/slf"
"github.com/mono83/slf/wd"
"github.com/elyby/chrly/dispatcher"
)
type Emitter interface {
Emit(name string, args ...interface{})
}
func Serve(address string, handler http.Handler) error {
listener, err := net.Listen("tcp", address)
if err != nil {
return err
}
server := &http.Server{
ReadTimeout: 5 * time.Second,
WriteTimeout: 5 * time.Second,
IdleTimeout: 60 * time.Second,
MaxHeaderBytes: 1 << 16,
Handler: handler,
}
return server.Serve(listener)
dispatcher.Emitter
}
func StartServer(server *http.Server, logger slf.Logger) {