本文整理汇总了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
}
示例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)
}
示例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)
}