# net/http: update docs for LocalAddrContextKey #21603

Closed
opened this issue Aug 25, 2017 · 10 comments
Closed

# net/http: update docs for LocalAddrContextKey#21603

opened this issue Aug 25, 2017 · 10 comments
Labels
Milestone

1.9

yes

amd64

### What did you do?

r is a *http.Request

### What did you see instead?

I replied to an older closed issue, I'm not sure if it will be seen or not so I am posting again: #18686
It seems that the functionality of LocalAddrContextKey has changed to what it was possibly intended to do, if so it should be mentioned in the patch notes

changed the title Update Go Doc for net/http LocalAddrContextKey net/http: update docs for LocalAddrContextKey Aug 25, 2017
added the label Aug 25, 2017

### ianlancetaylor commented Aug 25, 2017

 What do you mean by the "patch notes"? Do you mean the contents of https://golang.org/doc/go1.9? Or do you mean the documentation of LocalAddrContextKey at https://golang.org/pkg/net/http/#pkg-variables ?
added this to the Go1.10 milestone Aug 25, 2017

### sabey commented Aug 25, 2017 • edited

 sorry, I meant release notes, and yes http.LocalAddrContextKey

### ianlancetaylor commented Aug 25, 2017

 Thanks. Not every change is mentioned in the release notes, only the ones that seem important or significant. CC @tombergan Should this change be in the release notes?

### sabey commented Aug 25, 2017

 ya I figure, it was a shock to me however to find that I now had access to it

### elico commented Aug 25, 2017 • edited

 @ianlancetaylor sure! it should be documented and also mentioned in the release notes. It's important for many web server's for stats or the ability to apply ACL's for services that apply different policies for different networks their clients have access from\to. For example I have a service which face two different public ip addresses behind nat(each has it's own router) and I want to apply rate limiting only for connections coming on a specific internal ip address without running two different listening ports\services. (the reverse path route consistency is being handled by iptables)

### tombergan commented Aug 28, 2017

 Here is the documentation for LocalAddrContextKey: // LocalAddrContextKey is a context key. It can be used in // HTTP handlers with context.WithValue to access the address // the local address the connection arrived on. // The associated value will be of type net.Addr. LocalAddrContextKey = &contextKey{"local-addr"} @sabey, that looks correct to me? #18686 fixed a bug where LocalAddrContextKey used the listen address instead of the actual accepted address (where they could differ if the listen address was a wildcard). The fixed behavior seems to match the above comment. As to whether or not this belongs in the release notes, I don't feel strongly and am fine with adding it. It seems roughly at the same level as the ServeMux change called out in the release notes: https://golang.org/doc/go1.9#net/http

### gopherbot commented Aug 28, 2017

 Change https://golang.org/cl/59530 mentions this issue: doc/1.9: add mention of net/http.LocalAddrContextKey
closed this in  75d7a02  Aug 28, 2017

### sabey commented Aug 28, 2017

 @tombergan looks correct

### gopherbot commented Aug 28, 2017

 Change https://golang.org/cl/59670 mentions this issue: [release-branch.go1.9] doc/1.9: add mention of net/http.LocalAddrContextKey
pushed a commit that referenced this issue Aug 28, 2017
 [release-branch.go1.9] doc/1.9: add mention of net/http.LocalAddrCont… 
 f7339b3 
…extKey

Fixes #21603

Change-Id: I42fb7ea2dd7f6d6a201171055beaeda68c26b823
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>

### gopherbot commented Oct 4, 2017

 Change https://golang.org/cl/68232 mentions this issue: [release-branch.go1.9] doc/1.9: add mention of net/http.LocalAddrContextKey
pushed a commit that referenced this issue Oct 4, 2017
 [release-branch.go1.9] doc/1.9: add mention of net/http.LocalAddrCont… 
 815cad3 
…extKey

Fixes #21603

Reviewed-by: Ian Lance Taylor <iant@golang.org>

Change-Id: Ie9732d57948593dc0306a4a649664eedb3de370c
Reviewed-by: Chris Broadfoot <cbro@golang.org>