diff --git a/internal/app/xhttp/pkg/context/context.go b/internal/app/xhttp/pkg/context/context.go index cf49d205..25047b16 100644 --- a/internal/app/xhttp/pkg/context/context.go +++ b/internal/app/xhttp/pkg/context/context.go @@ -3,6 +3,7 @@ package context import ( "fmt" "net/http" + "reflect" "strconv" "time" @@ -124,6 +125,12 @@ func (ctx *Context) WithResource(directoryName string) error { return nil } +// HasResource returns true if the Context +// has a resource.Resource. +func (ctx Context) HasResource() bool { + return !reflect.DeepEqual(ctx.resource, resource.Resource{}) +} + /* MustResource returns the resource.Resource associated with the Context. @@ -138,12 +145,6 @@ func (ctx Context) MustResource() resource.Resource { return ctx.resource } -// HasResource returns true if the Context -// has a resource.Resource. -func (ctx Context) HasResource() bool { - return &ctx.resource != nil -} - /* LogRequestResult logs the result of a request. This method should only be used by a middleware!