Skip to content

Commit

Permalink
doc: fix doc comment
Browse files Browse the repository at this point in the history
  • Loading branch information
jumpeiMano committed May 7, 2020
1 parent c3c92a5 commit 720f86f
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,10 @@ func SetHTTPResponseHeader(ctx context.Context, key, value string) error {
return nil
}

// AddHTTPResponseHeader adds an HTTP header key-value pair using a context
// provided by a twirp-generated server, or a child of that context.
// The server will include the header in its response for that request context.
//
// This can be used to respond with custom HTTP headers like "Cache-Control".
// But note that HTTP headers are a Twirp implementation detail,
// only visible by middleware, not by the clients or their responses.
// AddHTTPResponseHeader behaves like SetHTTPResponseHeader,
// but it appends the key-value pair to the header (instead of replacing it).
//
// The header will be ignored (noop) if the context is invalid (i.e. using a new
// context.Background() instead of passing the context from the handler).
//
// If called multiple times with the same key, it appends to any existing values
// associated with that key.
//
// AddHTTPResponseHeader returns an error if the provided header key
// would overwrite a header that is needed by Twirp, like "Content-Type".
// AddHTTPResponseHeader returns an error if the key is "Content-Type".
func AddHTTPResponseHeader(ctx context.Context, key, value string) error {
if key == "Content-Type" {
return errors.New("header key can not be Content-Type")
Expand Down

0 comments on commit 720f86f

Please sign in to comment.