2013/3/6 minux <minux.ma@gmail.com>:
you will need to provide a custom listener to net/http.(*Server).Serve.
just wrap a standard net.Listener's Accept method with your filtering one.
type filteringListener struct { net.Listener }
func (fl filteringListener) Accept() (net.Conn, error) {
c, err := fl.Listener.Accept()
// fillter c
return c, err
}
My code now looks like this, does that mean , that i need to provide
my own net.Listen
function or i need to create variable with type filteringListener and
with type assertion
pass to it net.Listen listener ?
func server(conf Conf) {
r := http.NewServeMux()
r.HandleFunc("/", process)
http.Handle("/", r)
s := &http.Server{
Addr: ":80",
Handler: r,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
l, err := net.Listen("tcp", ":80")
if err != nil {
conf.Log.Panicf(err.Error())
}
go s.Serve(l)
select {
case <-conf.ServerClose:
conf.Log.Printf("Server thread exit")
l.Close()
return
break
}
}
--
Vasiliy Tolstov,
e-mail:
v.tolstov@selfip.rujabber:
vase@selfip.ru--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/groups/opt_out.