The Go Programming Language (Addison-Wesley Professional Computing Series) by Brian W. Kernighan
Author:Brian W. Kernighan [Kernighan, Brian W.]
Language: eng
Format: epub
Tags: Computers & Technology, Programming Languages, Reference, Programming
ISBN: 9780134190440
Amazon: B0184N7WWS
Publisher: Addison-Wesley Professional
Published: 2015-11-15T23:00:00+00:00
It’s easy to see from the code above how one would construct a program in which there are two different web servers, listening on different ports, defining different URLs, and dispatching to different handlers. We would just construct another ServeMux and make another call to ListenAndServe, perhaps concurrently. But in most programs, one web server is plenty. Also, it’s typical to define HTTP handlers across many files of an application, and it would be a nuisance if they all had to be explicitly registered with the application’s ServeMux instance.
So, for convenience, net/http provides a global ServeMux instance called DefaultServeMux and package-level functions called http.Handle and http.HandleFunc. To use DefaultServeMux as the server’s main handler, we needn’t pass it to ListenAndServe; nil will do.
The server’s main function can then be simplified to
Click here to view code image
gopl.io/ch7/http4
func main() { db := database{"shoes": 50, "socks": 5} http.HandleFunc("/list", db.list) http.HandleFunc("/price", db.price) log.Fatal(http.ListenAndServe("localhost:8000", nil)) }
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Ada | Ajax |
Assembly Language Programming | Borland Delphi |
C & C++ | C# |
CSS | Compiler Design |
Compilers | DHTML |
Debugging | Delphi |
Fortran | Java |
Lisp | Perl |
Prolog | Python |
RPG | Ruby |
Swift | Visual Basic |
XHTML | XML |
XSL |
Hello! Python by Anthony Briggs(9751)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9637)
The Mikado Method by Ola Ellnestam Daniel Brolund(9632)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8148)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7653)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7652)
Grails in Action by Glen Smith Peter Ledbrook(7565)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7390)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6279)
Windows APT Warfare by Sheng-Hao Ma(6027)
Layered Design for Ruby on Rails Applications by Vladimir Dementyev(5771)
Blueprints Visual Scripting for Unreal Engine 5 - Third Edition by Marcos Romero & Brenden Sewell(5629)
Kotlin in Action by Dmitry Jemerov(4918)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4223)
Functional Programming in JavaScript by Mantyla Dan(3942)
Solidity Programming Essentials by Ritesh Modi(3571)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3315)
Unity 3D Game Development by Anthony Davis & Travis Baptiste & Russell Craig & Ryan Stunkel(3285)
The Ultimate iOS Interview Playbook by Avi Tsadok(3245)
