diff --git a/source/Stargate-Model/HypermediaDrivenRESTfulRequestHandler.class.st b/source/Stargate-Model/HypermediaDrivenRESTfulRequestHandler.class.st index 2545b9d..da20fb0 100644 --- a/source/Stargate-Model/HypermediaDrivenRESTfulRequestHandler.class.st +++ b/source/Stargate-Model/HypermediaDrivenRESTfulRequestHandler.class.st @@ -37,17 +37,16 @@ HypermediaDrivenRESTfulRequestHandler >> encodeResource: resource as: mediaType { #category : 'private' } HypermediaDrivenRESTfulRequestHandler >> encodeResourceCollection: resourceCollection basedOn: httpRequest within: requestContext [ - requestContext - holdAsHypermediaControls: - ( self paginationPolicy - addPaginationControlsTo: ( Array with: 'self' -> httpRequest absoluteUrl ) - within: requestContext ) - for: resourceCollection. - resourceCollection do: [ :resource | self holdResource: resource controlsWithin: requestContext ]. - ^ super - encodeResourceCollection: ( ResourceCollection wrapping: resourceCollection ) - basedOn: httpRequest - within: requestContext + requestContext + holdAsHypermediaControls: ( self paginationPolicy + addPaginationControlsTo: { httpRequest absoluteUrl asWebLink toMyself } + within: requestContext ) + for: resourceCollection. + resourceCollection do: [ :resource | self holdResource: resource controlsWithin: requestContext ]. + ^ super + encodeResourceCollection: ( ResourceCollection wrapping: resourceCollection ) + basedOn: httpRequest + within: requestContext ] { #category : 'private' } diff --git a/source/Stargate-Model/MediaControlsBuilder.class.st b/source/Stargate-Model/MediaControlsBuilder.class.st index c290778..ce7dcea 100644 --- a/source/Stargate-Model/MediaControlsBuilder.class.st +++ b/source/Stargate-Model/MediaControlsBuilder.class.st @@ -28,13 +28,13 @@ MediaControlsBuilder >> addAsSelfLink: aUrl [ { #category : 'adding' } MediaControlsBuilder >> addLink: aUrl relatedTo: aRelationType [ - mediaControls add: aRelationType -> aUrl + mediaControls add: ( aUrl asWebLink relationType: aRelationType ) ] { #category : 'adding' } MediaControlsBuilder >> addRelativeLink: aRelativeUrl relatedTo: aRelationType [ - mediaControls add: aRelationType -> ( resourceLocatorBinding content baseUrl / aRelativeUrl ) + self addLink: resourceLocatorBinding content baseUrl / aRelativeUrl relatedTo: aRelationType ] { #category : 'building' } diff --git a/source/Stargate-Model/RESTfulControllerPaginateCollectionsPolicy.class.st b/source/Stargate-Model/RESTfulControllerPaginateCollectionsPolicy.class.st index 32ba8f9..c134779 100644 --- a/source/Stargate-Model/RESTfulControllerPaginateCollectionsPolicy.class.st +++ b/source/Stargate-Model/RESTfulControllerPaginateCollectionsPolicy.class.st @@ -28,11 +28,7 @@ RESTfulControllerPaginateCollectionsPolicy >> addPaginationControlsTo: mediaCont { #category : 'applying' } RESTfulControllerPaginateCollectionsPolicy >> affect: response within: requestContext [ - requestContext paginationControls do: [ :assoc | - response addLink: ( ( WebLink to: assoc value ) - relationType: assoc key; - yourself ) - ] + requestContext paginationControls do: [ :link | response addLink: link ] ] { #category : 'applying' } diff --git a/source/Stargate-NeoJSON-Extensions/NeoJSONObjectMapping.extension.st b/source/Stargate-NeoJSON-Extensions/NeoJSONObjectMapping.extension.st index d872c29..c070e36 100644 --- a/source/Stargate-NeoJSON-Extensions/NeoJSONObjectMapping.extension.st +++ b/source/Stargate-NeoJSON-Extensions/NeoJSONObjectMapping.extension.st @@ -3,9 +3,13 @@ Extension { #name : 'NeoJSONObjectMapping' } { #category : '*Stargate-NeoJSON-Extensions' } NeoJSONObjectMapping >> mapAsHypermediaControls: aBlock [ - self - mapProperty: #links - getter: [ :object | ( ( aBlock cull: object ) collect: [ :assoc | assoc key -> assoc value printString ] ) asDictionary ] + self mapProperty: #links getter: [ :object | + | controls | + controls := OrderedDictionary new. + ( aBlock cull: object ) do: [ :webLink | + controls at: webLink relationType put: webLink url printString ]. + controls + ] ] { #category : '*Stargate-NeoJSON-Extensions' }