Confusion about the doc for ServeMux

60 views
Skip to first unread message

Jingguo Yao

unread,
May 14, 2020, 4:16:47 AM5/14/20
to golang-nuts

> Host-specific patterns take precedence over general patterns, so that a handler might register for the two patterns "/codesearch" and "codesearch.google.com/" without also taking over requests for "http://www.google.com/".


  1. "/codesearch" means a path. "codesearch.google.com/" means a host "codesearch.google.com" and the subtree path "/". Does it mean that the latter takes precedence over the former?
  2. Does without also taking over requests for "http://www.google.com/" mean that the handler for "codesearch.google.com/" does not take requests for "http://www.google.com/"?
-----------
Jingguo

tokers

unread,
May 14, 2020, 8:27:23 AM5/14/20
to golang-nuts
  1. "/codesearch" means a path. "codesearch.google.com/" means a host "codesearch.google.com" and the subtree path "/". Does it mean that the latter takes precedence over the former?
Yes. A pattern starts with a host will be used firstly if matching successfully. 
  1. Does without also taking over requests for "http://www.google.com/" mean that the handler for "codesearch.google.com/" does not take requests for "http://www.google.com/"?
Yes. Pattern "codesearch.google.com/" only takes over requests which host is "codesearch.google.com". 
Reply all
Reply to author
Forward
0 new messages