fixing method HasResource

This commit is contained in:
Julien Neuhart
2019-07-24 10:20:36 +02:00
parent 84c1175379
commit 3ee4540f7d

View File

@@ -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!