Source File
response_helper.go
Belonging Package
github.com/apache/thrift/lib/go/thrift
/** Licensed to the Apache Software Foundation (ASF) under one* or more contributor license agreements. See the NOTICE file* distributed with this work for additional information* regarding copyright ownership. The ASF licenses this file* to you under the Apache License, Version 2.0 (the* "License"); you may not use this file except in compliance* with the License. You may obtain a copy of the License at** http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing,* software distributed under the License is distributed on an* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY* KIND, either express or implied. See the License for the* specific language governing permissions and limitations* under the License.*/package thriftimport ()// See https://godoc.org/context#WithValue on why do we need the unexported typedefs.type responseHelperKey struct{}// TResponseHelper defines a object with a set of helper functions that can be// retrieved from the context object passed into server handler functions.//// Use GetResponseHelper to retrieve the injected TResponseHelper implementation// from the context object.//// The zero value of TResponseHelper is valid with all helper functions being// no-op.type TResponseHelper struct {// THeader related functions*THeaderResponseHelper}// THeaderResponseHelper defines THeader related TResponseHelper functions.//// The zero value of *THeaderResponseHelper is valid with all helper functions// being no-op.type THeaderResponseHelper struct {proto *THeaderProtocol}// NewTHeaderResponseHelper creates a new THeaderResponseHelper from the// underlying TProtocol.func ( TProtocol) *THeaderResponseHelper {if , := .(*THeaderProtocol); {return &THeaderResponseHelper{proto: ,}}return nil}// SetHeader sets a response header.//// It's no-op if the underlying protocol/transport does not support THeader.func ( *THeaderResponseHelper) (, string) {if != nil && .proto != nil {.proto.SetWriteHeader(, )}}// ClearHeaders clears all the response headers previously set.//// It's no-op if the underlying protocol/transport does not support THeader.func ( *THeaderResponseHelper) () {if != nil && .proto != nil {.proto.ClearWriteHeaders()}}// GetResponseHelper retrieves the TResponseHelper implementation injected into// the context object.//// If no helper was found in the context object, a nop helper with ok == false// will be returned.func ( context.Context) ( TResponseHelper, bool) {if := .Value(responseHelperKey{}); != nil {, = .(TResponseHelper)}return}// SetResponseHelper injects TResponseHelper into the context object.func ( context.Context, TResponseHelper) context.Context {return context.WithValue(, responseHelperKey{}, )}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |