Skip to content

Commit

Permalink
Merge pull request #66 from ba-st/65-Allow-to-easily-create-entity-ha…
Browse files Browse the repository at this point in the history
…sh-from-the-encoded-resource

Added a configuring message to the request handler builder
  • Loading branch information
gcotelli authored Oct 7, 2019
2 parents 206d53c + ca3e881 commit b945b4b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ PetOrdersRESTfulController >> initializeCommentsRequestHandler [
whenAccepting: ZnMimeType textPlain decodeApplying: [ :comment | comment ];
whenResponding: ZnMimeType textPlain
encodeApplying: [ :resource | self encodeComments: resource ];
createEntityTagHashing: [ :hasher :comment :requestContext | hasher include: comment ];
createEntityTagHashingEncodedResource;
build
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ RESTfulRequestHandlerBehavior >> endpoint [
{ #category : #private }
RESTfulRequestHandlerBehavior >> entityTagOf: resource encodedAs: mediaType within: requestContext [

^ ZnETag with: ( entityTagCalculator value: resource value: mediaType value: requestContext )
^ ZnETag with: ( entityTagCalculator value: resource value: mediaType value: requestContext value: self )
]

{ #category : #private }
Expand Down
13 changes: 12 additions & 1 deletion source/Stargate-Model/RESTfulRequestHandlerBuilder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ RESTfulRequestHandlerBuilder >> build [
RESTfulRequestHandlerBuilder >> createEntityTagHashing: aBlockClosure [

self
createEntityTagWith: [ :resource :mediaType :requestContext |
createEntityTagWith: [ :resource :mediaType :requestContext :requestHandler |
| hasher |
hasher := EntityTagHasher new.
aBlockClosure cull: hasher cull: resource cull: requestContext.
Expand All @@ -67,6 +67,17 @@ RESTfulRequestHandlerBuilder >> createEntityTagHashing: aBlockClosure [
]
]

{ #category : #configuring }
RESTfulRequestHandlerBuilder >> createEntityTagHashingEncodedResource [

self
createEntityTagWith: [ :resource :mediaType :requestContext :requestHandler |
EntityTagHasher new
include: ( requestHandler encodeResource: resource to: mediaType within: requestContext );
calculateHash
]
]

{ #category : #configuring }
RESTfulRequestHandlerBuilder >> createEntityTagWith: aBlock [

Expand Down

0 comments on commit b945b4b

Please sign in to comment.