From 41b7c90d67603cab4fc315dad058404f0f4a6bd7 Mon Sep 17 00:00:00 2001 From: Ehsan Noureddin Moosa Date: Thu, 12 May 2022 17:52:04 +0430 Subject: [PATCH] add Limited method --- ctx.go | 6 ++++++ ctx_limited.go | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ctx.go b/ctx.go index b4f001bb..654550ec 100644 --- a/ctx.go +++ b/ctx.go @@ -172,6 +172,12 @@ func (ctx *Context) HasError() bool { return ctx.err != nil } +// Limited returns a LimitedContext. This is useful when you don't want to give all +// capabilities of the Context to some other function/method. +func (ctx *Context) Limited() *LimitedContext { + return newLimitedContext(ctx) +} + func (ctx *Context) reset() { for k := range ctx.kv { delete(ctx.kv, k) diff --git a/ctx_limited.go b/ctx_limited.go index 648f8c1f..f1fc3db3 100644 --- a/ctx_limited.go +++ b/ctx_limited.go @@ -54,7 +54,3 @@ func (ctx *LimitedContext) Route() string { func (ctx *LimitedContext) ServiceName() string { return ctx.ctx.ServiceName() } - -func (ctx *LimitedContext) Cluster() Cluster { - panic("not implemented") -}