OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // HTTP server. See RFC 2616. | 5 // HTTP server. See RFC 2616. |
6 | 6 |
7 // TODO(rsc): | 7 // TODO(rsc): |
8 // logging | 8 // logging |
9 // cgi support | 9 // cgi support |
10 // post support | 10 // post support |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 func ListenAndServe(addr string, handler Handler) os.Error { | 635 func ListenAndServe(addr string, handler Handler) os.Error { |
636 l, e := net.Listen("tcp", addr) | 636 l, e := net.Listen("tcp", addr) |
637 if e != nil { | 637 if e != nil { |
638 return e | 638 return e |
639 } | 639 } |
640 e = Serve(l, handler) | 640 e = Serve(l, handler) |
641 l.Close() | 641 l.Close() |
642 return e | 642 return e |
643 } | 643 } |
644 | 644 |
645 // ListenAndServeTLS acts identically to ListenAndServe, expect that it | 645 // ListenAndServeTLS acts identically to ListenAndServe, except that it |
646 // except HTTPS connections. Additionally, files containing a certificate and | 646 // expects HTTPS connections. Additionally, files containing a certificate and |
647 // matching private key for the server must be provided. | 647 // matching private key for the server must be provided. |
648 // | 648 // |
649 // A trivial example server is: | 649 // A trivial example server is: |
650 // | 650 // |
651 // import ( | 651 // import ( |
652 // "http" | 652 // "http" |
653 // "log" | 653 // "log" |
654 // ) | 654 // ) |
655 // | 655 // |
656 // func handler(conn *http.Conn, req *http.Request) { | 656 // func handler(conn *http.Conn, req *http.Request) { |
(...skipping 26 matching lines...) Expand all Loading... |
683 } | 683 } |
684 | 684 |
685 conn, err := net.Listen("tcp", addr) | 685 conn, err := net.Listen("tcp", addr) |
686 if err != nil { | 686 if err != nil { |
687 return err | 687 return err |
688 } | 688 } |
689 | 689 |
690 tlsListener := tls.NewListener(conn, config) | 690 tlsListener := tls.NewListener(conn, config) |
691 return Serve(tlsListener, handler) | 691 return Serve(tlsListener, handler) |
692 } | 692 } |
OLD | NEW |