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


Golang Operation.GetRequest方法代码示例

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


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

示例1: HandleRequest

func (s *ServiceContext) HandleRequest(ctx context.Context, op *operation.Operation) {
	switch op.GetRequest().Method {
	case "GET":
		if s.hGet != nil {
			s.hGet(ctx, op)
			return
		}
	case "POST":
		if s.hPost != nil {
			s.hPost(ctx, op)
			return
		}
	case "PATCH":
		if s.hPatch != nil {
			s.hPatch(ctx, op)
			return
		}
	case "PUT":
		if s.hPut != nil {
			s.hPut(ctx, op)
			return
		}
	case "DELETE":
		if s.hDelete != nil {
			s.hDelete(ctx, op)
			return
		}
	}

	op.Fail(errors.MethodNotAllowed{Allowed: s.allowedMethods()})
	return
}
开发者ID:vmware,项目名称:xenon,代码行数:32,代码来源:service_context.go

示例2: HandleRequest

func (h *ServiceHost) HandleRequest(ctx context.Context, op *operation.Operation) {
	selfLink := path.Clean(op.GetRequest().URL.Path)

	h.RLock()
	s, ok := h.services[selfLink]
	h.RUnlock()

	if !ok {
		// TODO(PN): Check if the path points to a utility service
		op.SetStatusCode(http.StatusNotFound).Complete()
		return
	}

	// Queue request if service is not yet available
	if s.Stage() < StageAvailable {
		select {
		case <-op.Done():
			return // Operation is already done, no need to complete.
		case <-s.StageBarrier(StageAvailable):
			// Continue
		}
	}

	s.HandleRequest(ctx, op)
}
开发者ID:vmware,项目名称:xenon,代码行数:25,代码来源:service_host.go

示例3: HandleRequest

func (f *FactoryServiceContext) HandleRequest(ctx context.Context, op *operation.Operation) {
	// TODO(PN): Support GET (need a way to get elements) and DELETE
	switch op.GetRequest().Method {
	case "POST":
	default:
		err := errors.MethodNotAllowed{Allowed: []string{"POST"}}
		op.Fail(err)
		return
	}

	f.handlePost(ctx, op)
}
开发者ID:vmware,项目名称:xenon,代码行数:12,代码来源:factory_service_context.go


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