|
|
@ -16,6 +16,7 @@ import (
|
|
|
|
"github.com/fangdingjun/gnutls"
|
|
|
|
"github.com/fangdingjun/gnutls"
|
|
|
|
auth "github.com/fangdingjun/go-http-auth"
|
|
|
|
auth "github.com/fangdingjun/go-http-auth"
|
|
|
|
"github.com/fangdingjun/gofast"
|
|
|
|
"github.com/fangdingjun/gofast"
|
|
|
|
|
|
|
|
loghandler "github.com/gorilla/handlers"
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -32,19 +33,17 @@ func (lw *logwriter) Write(buf []byte) (int, error) {
|
|
|
|
|
|
|
|
|
|
|
|
func initRouters(cfg conf) {
|
|
|
|
func initRouters(cfg conf) {
|
|
|
|
|
|
|
|
|
|
|
|
//logout := os.Stdout
|
|
|
|
logout := os.Stdout
|
|
|
|
/*
|
|
|
|
if logfile != "" {
|
|
|
|
if logfile != "" {
|
|
|
|
fp, err := os.OpenFile(logfile, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644)
|
|
|
|
fp, err := os.OpenFile(logfile, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
log.Println(err)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
logout = fp
|
|
|
|
logout = fp
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//w := &logwriter{logout, new(sync.Mutex)}
|
|
|
|
w := &logwriter{logout, new(sync.Mutex)}
|
|
|
|
|
|
|
|
|
|
|
|
for _, l := range cfg {
|
|
|
|
for _, l := range cfg {
|
|
|
|
router := mux.NewRouter()
|
|
|
|
router := mux.NewRouter()
|
|
|
@ -137,8 +136,8 @@ func initRouters(cfg conf) {
|
|
|
|
log.Fatal(err)
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//handler := loghandler.CombinedLoggingHandler(w, hdlr)
|
|
|
|
handler := loghandler.CombinedLoggingHandler(w, hdlr)
|
|
|
|
handler := hdlr
|
|
|
|
//handler := hdlr
|
|
|
|
log.Printf("listen https on %s", addr)
|
|
|
|
log.Printf("listen https on %s", addr)
|
|
|
|
go func() {
|
|
|
|
go func() {
|
|
|
|
defer listener.Close()
|
|
|
|
defer listener.Close()
|
|
|
@ -154,8 +153,8 @@ func initRouters(cfg conf) {
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
log.Printf("listen http on %s", addr)
|
|
|
|
log.Printf("listen http on %s", addr)
|
|
|
|
//handler := loghandler.CombinedLoggingHandler(w, hdlr),
|
|
|
|
handler := loghandler.CombinedLoggingHandler(w, hdlr)
|
|
|
|
handler := hdlr
|
|
|
|
//handler := hdlr
|
|
|
|
if err := http.ListenAndServe(
|
|
|
|
if err := http.ListenAndServe(
|
|
|
|
addr, handler,
|
|
|
|
addr, handler,
|
|
|
|
); err != nil {
|
|
|
|
); err != nil {
|
|
|
|