当前位置: 首页>>代码示例>>Golang>>正文


Golang Context.SetResponseHeaders方法代码示例

本文整理汇总了Golang中github.com/uber/tchannel-go/thrift.Context.SetResponseHeaders方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.SetResponseHeaders方法的具体用法?Golang Context.SetResponseHeaders怎么用?Golang Context.SetResponseHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/uber/tchannel-go/thrift.Context的用法示例。


在下文中一共展示了Context.SetResponseHeaders方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestException

func (thriftTestHandler) TestException(ctx thrift.Context, arg string) error {
	ctx.SetResponseHeaders(ctx.Headers())
	switch arg {
	case "Xception":
		code := int32(1001)
		return &gauntlet_tchannel.Xception{ErrorCode: &code, Message: &arg}
	case "TException":
		// unexpected exception.
		return errors.New("great sadness")
	default:
		return nil
	}
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:13,代码来源:gauntlet.go

示例2: Set

// Set sets the value for a given key.
func (h *kvHandler) Set(ctx thrift.Context, key, value string) error {
	if err := isValidKey(key); err != nil {
		return err
	}

	h.mut.Lock()
	defer h.mut.Unlock()

	h.vals[key] = value
	// Example of how to use response headers. Normally, these values should be passed via result structs.
	ctx.SetResponseHeaders(map[string]string{"count": fmt.Sprint(len(h.vals))})
	return nil
}
开发者ID:glycerine,项目名称:tchannel-go,代码行数:14,代码来源:server.go

示例3: TestMultiException

func (thriftTestHandler) TestMultiException(ctx thrift.Context, arg0 string, arg1 string) (*gauntlet_tchannel.Xtruct, error) {
	ctx.SetResponseHeaders(ctx.Headers())
	structThing := &gauntlet_tchannel.Xtruct{StringThing: &arg1}
	switch arg0 {
	case "Xception":
		code := int32(1001)
		message := "This is an Xception"
		return nil, &gauntlet_tchannel.Xception{ErrorCode: &code, Message: &message}
	case "Xception2":
		code := int32(2002)
		return nil, &gauntlet_tchannel.Xception2{ErrorCode: &code, StructThing: structThing}
	default:
		return structThing, nil
	}
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:15,代码来源:gauntlet.go

示例4: TestInsanity

func (thriftTestHandler) TestInsanity(ctx thrift.Context, argument *gauntlet_tchannel.Insanity) (
	map[gauntlet_tchannel.UserId]map[gauntlet_tchannel.Numberz]*gauntlet_tchannel.Insanity, error) {

	ctx.SetResponseHeaders(ctx.Headers())
	result := map[gauntlet_tchannel.UserId]map[gauntlet_tchannel.Numberz]*gauntlet_tchannel.Insanity{
		1: {
			gauntlet_tchannel.Numberz_TWO:   argument,
			gauntlet_tchannel.Numberz_THREE: argument,
		},
		2: {
			gauntlet_tchannel.Numberz_SIX: &gauntlet_tchannel.Insanity{},
		},
	}
	return result, nil
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:15,代码来源:gauntlet.go

示例5: TestMapMap

func (thriftTestHandler) TestMapMap(ctx thrift.Context, hello int32) (map[int32]map[int32]int32, error) {
	ctx.SetResponseHeaders(ctx.Headers())
	result := map[int32]map[int32]int32{
		-4: {
			-4: -4,
			-3: -3,
			-2: -2,
			-1: -1,
		},
		4: {
			1: 1,
			2: 2,
			3: 3,
			4: 4,
		},
	}
	return result, nil
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:18,代码来源:gauntlet.go

示例6: TestMulti

func (thriftTestHandler) TestMulti(
	ctx thrift.Context,
	arg0 int8,
	arg1 int32,
	arg2 int64,
	arg3 map[int16]string,
	arg4 gauntlet_tchannel.Numberz,
	arg5 gauntlet_tchannel.UserId,
) (*gauntlet_tchannel.Xtruct, error) {

	ctx.SetResponseHeaders(ctx.Headers())
	hello := "Hello2"
	result := &gauntlet_tchannel.Xtruct{
		StringThing: &hello,
		ByteThing:   &arg0,
		I32Thing:    &arg1,
		I64Thing:    &arg2,
	}
	return result, nil
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:20,代码来源:gauntlet.go

示例7: TestSet

func (thriftTestHandler) TestSet(ctx thrift.Context, thing map[int32]bool) (map[int32]bool, error) {
	ctx.SetResponseHeaders(ctx.Headers())
	return thing, nil
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:4,代码来源:gauntlet.go

示例8: TestStringMap

func (thriftTestHandler) TestStringMap(ctx thrift.Context, thing map[string]string) (map[string]string, error) {
	ctx.SetResponseHeaders(ctx.Headers())
	return thing, nil
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:4,代码来源:gauntlet.go

示例9: TestNest

func (thriftTestHandler) TestNest(ctx thrift.Context, thing *gauntlet_tchannel.Xtruct2) (*gauntlet_tchannel.Xtruct2, error) {
	ctx.SetResponseHeaders(ctx.Headers())
	return thing, nil
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:4,代码来源:gauntlet.go

示例10: TestBinary

func (thriftTestHandler) TestBinary(ctx thrift.Context, thing []byte) ([]byte, error) {
	ctx.SetResponseHeaders(ctx.Headers())
	return thing, nil
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:4,代码来源:gauntlet.go

示例11: TestDouble

func (thriftTestHandler) TestDouble(ctx thrift.Context, thing float64) (float64, error) {
	ctx.SetResponseHeaders(ctx.Headers())
	return thing, nil
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:4,代码来源:gauntlet.go

示例12: SecondtestString

func (secondServiceHandler) SecondtestString(ctx thrift.Context, thing string) (string, error) {
	ctx.SetResponseHeaders(ctx.Headers())
	return thing, nil
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:4,代码来源:gauntlet.go

示例13: BlahBlah

func (secondServiceHandler) BlahBlah(ctx thrift.Context) error {
	ctx.SetResponseHeaders(ctx.Headers())
	return nil
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:4,代码来源:gauntlet.go

示例14: TestList

func (thriftTestHandler) TestList(ctx thrift.Context, thing []int32) ([]int32, error) {
	ctx.SetResponseHeaders(ctx.Headers())
	return thing, nil
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:4,代码来源:gauntlet.go

示例15: TestVoid

func (thriftTestHandler) TestVoid(ctx thrift.Context) error {
	ctx.SetResponseHeaders(ctx.Headers())
	return nil
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:4,代码来源:gauntlet.go


注:本文中的github.com/uber/tchannel-go/thrift.Context.SetResponseHeaders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。