diff --git a/source/Stargate-Model/AllowAnyOriginPolicy.class.st b/source/Stargate-Model/AllowAnyOriginPolicy.class.st index 5b8e5ed..392c29a 100644 --- a/source/Stargate-Model/AllowAnyOriginPolicy.class.st +++ b/source/Stargate-Model/AllowAnyOriginPolicy.class.st @@ -2,14 +2,12 @@ I'm a policy configuring a CORS filter in such a way that sets Access-Control-Allow-Origin header to allow any origin. " Class { - #name : 'AllowAnyOriginPolicy', - #superclass : 'AllowOriginPolicy', - #category : 'Stargate-Model-CORS', - #package : 'Stargate-Model', - #tag : 'CORS' + #name : #AllowAnyOriginPolicy, + #superclass : #AllowOriginPolicy, + #category : 'Stargate-Model-CORS' } -{ #category : 'configuring headers' } +{ #category : #'configuring headers' } AllowAnyOriginPolicy >> applyOn: aResponse for: aRequest using: aHandler [ aHandler setAnyOriginAllowedOn: aResponse diff --git a/source/Stargate-Model/AllowOriginPolicy.class.st b/source/Stargate-Model/AllowOriginPolicy.class.st index d86957e..7f3e09a 100644 --- a/source/Stargate-Model/AllowOriginPolicy.class.st +++ b/source/Stargate-Model/AllowOriginPolicy.class.st @@ -1,12 +1,10 @@ Class { - #name : 'AllowOriginPolicy', - #superclass : 'Object', - #category : 'Stargate-Model-CORS', - #package : 'Stargate-Model', - #tag : 'CORS' + #name : #AllowOriginPolicy, + #superclass : #Object, + #category : 'Stargate-Model-CORS' } -{ #category : 'configuring headers' } +{ #category : #'configuring headers' } AllowOriginPolicy >> applyOn: aResponse for: aRequest using: aHandler [ self subclassResponsibility diff --git a/source/Stargate-Model/AllowSpecifiedOriginsPolicy.class.st b/source/Stargate-Model/AllowSpecifiedOriginsPolicy.class.st index 004770d..1b998dd 100644 --- a/source/Stargate-Model/AllowSpecifiedOriginsPolicy.class.st +++ b/source/Stargate-Model/AllowSpecifiedOriginsPolicy.class.st @@ -2,23 +2,21 @@ I'm a policy configuring a CORS filter in such a way that sets Access-Control-Allow-Origin header to a specified set of origins. " Class { - #name : 'AllowSpecifiedOriginsPolicy', - #superclass : 'AllowOriginPolicy', + #name : #AllowSpecifiedOriginsPolicy, + #superclass : #AllowOriginPolicy, #instVars : [ 'allowedOrigins' ], - #category : 'Stargate-Model-CORS', - #package : 'Stargate-Model', - #tag : 'CORS' + #category : 'Stargate-Model-CORS' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } AllowSpecifiedOriginsPolicy class >> onlyFrom: anUrlCollection [ ^ self new initializeOnlyFrom: ( anUrlCollection collect: #asWebOrigin ) ] -{ #category : 'configuring headers' } +{ #category : #'configuring headers' } AllowSpecifiedOriginsPolicy >> applyOn: aResponse for: aRequest using: aHandler [ | requestOrigin | @@ -34,7 +32,7 @@ AllowSpecifiedOriginsPolicy >> applyOn: aResponse for: aRequest using: aHandler ifNone: [ aRequest abort: TeaResponse noContent ] ] -{ #category : 'initialization' } +{ #category : #initialization } AllowSpecifiedOriginsPolicy >> initializeOnlyFrom: origins [ allowedOrigins := origins diff --git a/source/Stargate-Model/AuthenticationFilter.class.st b/source/Stargate-Model/AuthenticationFilter.class.st index bbf5bae..386b269 100644 --- a/source/Stargate-Model/AuthenticationFilter.class.st +++ b/source/Stargate-Model/AuthenticationFilter.class.st @@ -2,14 +2,12 @@ I'm an abstract class representing an authentication filter to be applied as a before filter and perform an auth validation. I will take into consideration the Authorization header on the request and return a 401 / Unauthorized in case the credentials are invalid. " Class { - #name : 'AuthenticationFilter', - #superclass : 'Object', - #category : 'Stargate-Model-Auth', - #package : 'Stargate-Model', - #tag : 'Auth' + #name : #AuthenticationFilter, + #superclass : #Object, + #category : 'Stargate-Model-Auth' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } AuthenticationFilter class >> basedOn: configuration [ ^ self allSubclasses @@ -18,37 +16,37 @@ AuthenticationFilter class >> basedOn: configuration [ ifNone: [ self signalMissingConfiguration ] ] -{ #category : 'private' } +{ #category : #private } AuthenticationFilter class >> canHandle: configuration [ ^ self subclassResponsibility ] -{ #category : 'private' } +{ #category : #private } AuthenticationFilter class >> configuredBy: configuration [ ^ self subclassResponsibility ] -{ #category : 'private' } +{ #category : #private } AuthenticationFilter class >> signalMissingConfiguration [ ^ ObjectNotFound signal: 'Missing authentication configuration' ] -{ #category : 'accessing' } +{ #category : #accessing } AuthenticationFilter >> authChallenge [ ^ self subclassResponsibility ] -{ #category : 'private' } +{ #category : #private } AuthenticationFilter >> checkCredentials: authorization for: httpRequest within: requestContext ifInvalid: aBlock [ self subclassResponsibility ] -{ #category : 'evaluating' } +{ #category : #evaluating } AuthenticationFilter >> evaluateActionOnRequest: httpRequest within: requestContext [ | authorization | @@ -63,7 +61,7 @@ AuthenticationFilter >> evaluateActionOnRequest: httpRequest within: requestCont ifInvalid: [ httpRequest abort: ( ZnResponse unauthorized: self authChallenge ) ] ] -{ #category : 'evaluating' } +{ #category : #evaluating } AuthenticationFilter >> teaEvalActionOnRequest: httpRequest [ self evaluateActionOnRequest: httpRequest within: HttpRequestContext new diff --git a/source/Stargate-Model/CachingDirectivesBuilder.class.st b/source/Stargate-Model/CachingDirectivesBuilder.class.st index dd6292e..6aa9836 100644 --- a/source/Stargate-Model/CachingDirectivesBuilder.class.st +++ b/source/Stargate-Model/CachingDirectivesBuilder.class.st @@ -2,18 +2,16 @@ I'm a builder of caching headers, translating a Smalltalk expression inside a block into a command that adds a cache-control header (and the expires header) to the response before being sent. " Class { - #name : 'CachingDirectivesBuilder', - #superclass : 'Object', + #name : #CachingDirectivesBuilder, + #superclass : #Object, #instVars : [ 'directives', 'currentCondition' ], - #category : 'Stargate-Model-Caching', - #package : 'Stargate-Model', - #tag : 'Caching' + #category : 'Stargate-Model-Caching' } -{ #category : 'private' } +{ #category : #private } CachingDirectivesBuilder >> addCacheControlNamed: aName [ | condition | @@ -24,25 +22,25 @@ CachingDirectivesBuilder >> addCacheControlNamed: aName [ [ :response :context :resource | ( condition cull: response cull: resource ) then: [ response addCachingDirective: aName ] ] ] -{ #category : 'private' } +{ #category : #private } CachingDirectivesBuilder >> addCacheControlNamed: aName withString: aString [ self addCacheControlNamed: ( '<1s>="<2s>"' expandMacrosWith: aName with: aString ) ] -{ #category : 'private' } +{ #category : #private } CachingDirectivesBuilder >> addCacheControlNamed: aName withToken: aValue [ self addCacheControlNamed: ( '<1s>=<2p>' expandMacrosWith: aName with: aValue ) ] -{ #category : 'private' } +{ #category : #private } CachingDirectivesBuilder >> alwaysApplyDirectives [ currentCondition := [ :response | true ] ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> beAvailableFor: aDuration [ ^ self @@ -51,19 +49,19 @@ CachingDirectivesBuilder >> beAvailableFor: aDuration [ expireIn: aDuration ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> beImmutable [ self addCacheControlNamed: 'immutable' ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> bePrivate [ self addCacheControlNamed: 'private' ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> bePrivateRestrictedTo: aFieldNameCollection [ | fieldsString | @@ -72,37 +70,37 @@ CachingDirectivesBuilder >> bePrivateRestrictedTo: aFieldNameCollection [ self addCacheControlNamed: 'private' withString: fieldsString ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> bePublic [ self addCacheControlNamed: 'public' ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> beStaleAfter: aDuration [ self addCacheControlNamed: 'Max-Age' withToken: aDuration asSeconds ] -{ #category : 'building' } +{ #category : #building } CachingDirectivesBuilder >> build [ ^ directives ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> configureUsing: aBlock [ aBlock cull: self ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> doNotCache [ self addCacheControlNamed: 'no-cache' ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> doNotCacheRestrictedTo: aFieldNameCollection [ | fieldsString | @@ -111,7 +109,7 @@ CachingDirectivesBuilder >> doNotCacheRestrictedTo: aFieldNameCollection [ self addCacheControlNamed: 'no-cache' withString: fieldsString ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> doNotExpire [ ^ self @@ -119,19 +117,19 @@ CachingDirectivesBuilder >> doNotExpire [ beAvailableFor: 365000000 seconds ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> doNotStore [ self addCacheControlNamed: 'no-store' ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> doNotTransform [ self addCacheControlNamed: 'no-transform' ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> expireIn: aDuration [ | condition | @@ -144,7 +142,7 @@ CachingDirectivesBuilder >> expireIn: aDuration [ ] ] -{ #category : 'private' } +{ #category : #private } CachingDirectivesBuilder >> fieldStringFor: aFieldNameCollection [ ^ String @@ -158,7 +156,7 @@ CachingDirectivesBuilder >> fieldStringFor: aFieldNameCollection [ ] ] -{ #category : 'initialization' } +{ #category : #initialization } CachingDirectivesBuilder >> initialize [ super initialize. @@ -166,13 +164,13 @@ CachingDirectivesBuilder >> initialize [ self alwaysApplyDirectives ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> mustRevalidate [ self addCacheControlNamed: 'must-revalidate' ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> requireRevalidation [ self @@ -180,7 +178,7 @@ CachingDirectivesBuilder >> requireRevalidation [ beStaleAfter: 0 seconds ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> when: aResponseCondition apply: aDirectiveConfiguration [ [ currentCondition := aResponseCondition. @@ -189,13 +187,13 @@ CachingDirectivesBuilder >> when: aResponseCondition apply: aDirectiveConfigurat ensure: [ self alwaysApplyDirectives ] ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> whenSharedBeStaleAfter: aDuration [ self addCacheControlNamed: 'S-MaxAge' withToken: aDuration asSeconds ] -{ #category : 'configuring' } +{ #category : #configuring } CachingDirectivesBuilder >> whenSharedMustRevalidate [ self addCacheControlNamed: 'proxy-revalidate' diff --git a/source/Stargate-Model/CrossOriginResourceSharingActualRequestHandler.class.st b/source/Stargate-Model/CrossOriginResourceSharingActualRequestHandler.class.st index bd66d88..2f5f6bd 100644 --- a/source/Stargate-Model/CrossOriginResourceSharingActualRequestHandler.class.st +++ b/source/Stargate-Model/CrossOriginResourceSharingActualRequestHandler.class.st @@ -2,43 +2,41 @@ I'm a after filter handler for the actual request. I add CORS specific headers to the response. " Class { - #name : 'CrossOriginResourceSharingActualRequestHandler', - #superclass : 'CrossOriginResourceSharingHandler', + #name : #CrossOriginResourceSharingActualRequestHandler, + #superclass : #CrossOriginResourceSharingHandler, #instVars : [ 'allowOriginPolicy', 'optionalHeaderCommands' ], - #category : 'Stargate-Model-CORS', - #package : 'Stargate-Model', - #tag : 'CORS' + #category : 'Stargate-Model-CORS' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } CrossOriginResourceSharingActualRequestHandler class >> allowing: anAllowOriginPolicy applying: addHeaderCommands [ ^ self new initializeAllowing: anAllowOriginPolicy applying: addHeaderCommands ] -{ #category : 'initialization' } +{ #category : #initialization } CrossOriginResourceSharingActualRequestHandler >> initializeAllowing: anAllowOriginPolicy applying: aCommandCollection [ allowOriginPolicy := anAllowOriginPolicy. optionalHeaderCommands := aCommandCollection. ] -{ #category : 'private - evaluating' } +{ #category : #'private - evaluating' } CrossOriginResourceSharingActualRequestHandler >> setAllowedOriginOn: aResponse from: aRequest [ allowOriginPolicy applyOn: aResponse for: aRequest using: self ] -{ #category : 'private - evaluating' } +{ #category : #'private - evaluating' } CrossOriginResourceSharingActualRequestHandler >> setOptionalHeadersOn: aResponse [ optionalHeaderCommands do: [ :command | command value: aResponse headers value: self headerNames ] ] -{ #category : 'evaluating' } +{ #category : #evaluating } CrossOriginResourceSharingActualRequestHandler >> teaEvalActionOnRequest: aRequest response: aResponse [ self setAllowedOriginOn: aResponse from: aRequest. diff --git a/source/Stargate-Model/CrossOriginResourceSharingActualRequestHandlerBuilder.class.st b/source/Stargate-Model/CrossOriginResourceSharingActualRequestHandlerBuilder.class.st index 1c64d87..c71e692 100644 --- a/source/Stargate-Model/CrossOriginResourceSharingActualRequestHandlerBuilder.class.st +++ b/source/Stargate-Model/CrossOriginResourceSharingActualRequestHandlerBuilder.class.st @@ -2,44 +2,42 @@ I'm a builder for CrossOriginResourceSharingActualRequestHandler instances. " Class { - #name : 'CrossOriginResourceSharingActualRequestHandlerBuilder', - #superclass : 'CrossOriginResourceSharingRequestHandlerBuilder', + #name : #CrossOriginResourceSharingActualRequestHandlerBuilder, + #superclass : #CrossOriginResourceSharingRequestHandlerBuilder, #instVars : [ 'allowOriginPolicyBinding', 'addHeaderCommands' ], - #category : 'Stargate-Model-CORS', - #package : 'Stargate-Model', - #tag : 'CORS' + #category : 'Stargate-Model-CORS' } -{ #category : 'configuring' } +{ #category : #configuring } CrossOriginResourceSharingActualRequestHandlerBuilder >> allowAnyOrigin [ allowOriginPolicyBinding := Binding to: AllowAnyOriginPolicy new. ] -{ #category : 'configuring' } +{ #category : #configuring } CrossOriginResourceSharingActualRequestHandlerBuilder >> allowCredentials [ addHeaderCommands add: [ :headers :headerNames | headers at: headerNames >> #accessControlAllowCredentials put: true asString ] ] -{ #category : 'configuring' } +{ #category : #configuring } CrossOriginResourceSharingActualRequestHandlerBuilder >> allowOnlyFrom: origins [ allowOriginPolicyBinding := Binding to: ( AllowSpecifiedOriginsPolicy onlyFrom: origins ) ] -{ #category : 'building' } +{ #category : #building } CrossOriginResourceSharingActualRequestHandlerBuilder >> build [ ^ CrossOriginResourceSharingActualRequestHandler allowing: allowOriginPolicyBinding content applying: addHeaderCommands ] -{ #category : 'configuring' } +{ #category : #configuring } CrossOriginResourceSharingActualRequestHandlerBuilder >> expose: exposedHeaders [ addHeaderCommands @@ -50,7 +48,7 @@ CrossOriginResourceSharingActualRequestHandlerBuilder >> expose: exposedHeaders ] ] -{ #category : 'initialization' } +{ #category : #initialization } CrossOriginResourceSharingActualRequestHandlerBuilder >> initialize [ super initialize. diff --git a/source/Stargate-Model/CrossOriginResourceSharingFilter.class.st b/source/Stargate-Model/CrossOriginResourceSharingFilter.class.st index dd9b008..2df6268 100644 --- a/source/Stargate-Model/CrossOriginResourceSharingFilter.class.st +++ b/source/Stargate-Model/CrossOriginResourceSharingFilter.class.st @@ -2,23 +2,21 @@ I'm a filter used to add CORS support to a HTTPBasedRESTfulAPI instance " Class { - #name : 'CrossOriginResourceSharingFilter', - #superclass : 'Object', + #name : #CrossOriginResourceSharingFilter, + #superclass : #Object, #instVars : [ 'filter' ], - #category : 'Stargate-Model-CORS', - #package : 'Stargate-Model', - #tag : 'CORS' + #category : 'Stargate-Model-CORS' } -{ #category : 'private - instance creation' } +{ #category : #'private - instance creation' } CrossOriginResourceSharingFilter class >> applying: aFilter [ ^ self new initializeApplying: aFilter ] -{ #category : 'instance creation' } +{ #category : #'instance creation' } CrossOriginResourceSharingFilter class >> handleActualRequestByEvaluating: aHandler [ ^ self @@ -29,7 +27,7 @@ CrossOriginResourceSharingFilter class >> handleActualRequestByEvaluating: aHand ] ] -{ #category : 'instance creation' } +{ #category : #'instance creation' } CrossOriginResourceSharingFilter class >> handlePreflightByEvaluating: aHandler [ ^ self applying: [ :teapotServer | @@ -39,19 +37,19 @@ CrossOriginResourceSharingFilter class >> handlePreflightByEvaluating: aHandler ] ] -{ #category : 'testing' } +{ #category : #testing } CrossOriginResourceSharingFilter class >> isForPreflight: request [ ^ ( request headers includesKey: 'Origin' ) and: [ request method = #OPTIONS ] ] -{ #category : 'applying' } +{ #category : #applying } CrossOriginResourceSharingFilter >> applyOn: aTeapot [ filter value: aTeapot ] -{ #category : 'initialization' } +{ #category : #initialization } CrossOriginResourceSharingFilter >> initializeApplying: aBlock [ filter := aBlock diff --git a/source/Stargate-Model/CrossOriginResourceSharingFilterBuilder.class.st b/source/Stargate-Model/CrossOriginResourceSharingFilterBuilder.class.st index bf73bd6..c72ca69 100644 --- a/source/Stargate-Model/CrossOriginResourceSharingFilterBuilder.class.st +++ b/source/Stargate-Model/CrossOriginResourceSharingFilterBuilder.class.st @@ -2,31 +2,29 @@ I'm a filter builder. I aim to provide a clean interface to configure CORS support during the configuration of a HTTPBasedRESTfulAPI instance. " Class { - #name : 'CrossOriginResourceSharingFilterBuilder', - #superclass : 'Object', + #name : #CrossOriginResourceSharingFilterBuilder, + #superclass : #Object, #instVars : [ 'actualRequestHandlerBuilder', 'preflightHandlerBuilder', 'actualRequestHandlerBinding' ], - #category : 'Stargate-Model-CORS', - #package : 'Stargate-Model', - #tag : 'CORS' + #category : 'Stargate-Model-CORS' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } CrossOriginResourceSharingFilterBuilder class >> using: aControllerCollection [ ^ self new initializeUsing: aControllerCollection ] -{ #category : 'accessing' } +{ #category : #accessing } CrossOriginResourceSharingFilterBuilder >> actualRequestHandler [ ^ actualRequestHandlerBinding content ] -{ #category : 'configuring' } +{ #category : #configuring } CrossOriginResourceSharingFilterBuilder >> allowAnyOrigin [ preflightHandlerBuilder allowAnyOrigin. @@ -34,21 +32,21 @@ CrossOriginResourceSharingFilterBuilder >> allowAnyOrigin [ ] -{ #category : 'configuring' } +{ #category : #configuring } CrossOriginResourceSharingFilterBuilder >> allowCredentials [ actualRequestHandlerBuilder allowCredentials. preflightHandlerBuilder allowCredentials ] -{ #category : 'configuring' } +{ #category : #configuring } CrossOriginResourceSharingFilterBuilder >> allowOnlyFrom: origins [ preflightHandlerBuilder allowOnlyFrom: origins. actualRequestHandlerBuilder allowOnlyFrom: origins ] -{ #category : 'initialization' } +{ #category : #initialization } CrossOriginResourceSharingFilterBuilder >> allowedMethodsFrom: aControllerCollection [ | routes allowedMethods | @@ -70,40 +68,40 @@ CrossOriginResourceSharingFilterBuilder >> allowedMethodsFrom: aControllerCollec preflightHandlerBuilder allowMethods: allowedMethods ] -{ #category : 'building' } +{ #category : #building } CrossOriginResourceSharingFilterBuilder >> buildActualRequestFilter [ actualRequestHandlerBinding := Binding to: actualRequestHandlerBuilder build. ^ CrossOriginResourceSharingFilter handleActualRequestByEvaluating: self actualRequestHandler ] -{ #category : 'building' } +{ #category : #building } CrossOriginResourceSharingFilterBuilder >> buildPreflightFilter [ ^ CrossOriginResourceSharingFilter handlePreflightByEvaluating: preflightHandlerBuilder build ] -{ #category : 'configuring' } +{ #category : #configuring } CrossOriginResourceSharingFilterBuilder >> doNotCache [ preflightHandlerBuilder doNotCache ] -{ #category : 'configuring' } +{ #category : #configuring } CrossOriginResourceSharingFilterBuilder >> expireIn: aDuration [ preflightHandlerBuilder expireIn: aDuration ] -{ #category : 'configuring' } +{ #category : #configuring } CrossOriginResourceSharingFilterBuilder >> expose: headers [ preflightHandlerBuilder expose: headers. actualRequestHandlerBuilder expose: headers ] -{ #category : 'initialization' } +{ #category : #initialization } CrossOriginResourceSharingFilterBuilder >> initializeUsing: aControllerCollection [ preflightHandlerBuilder := CrossOriginResourceSharingPreflightHandlerBuilder new. diff --git a/source/Stargate-Model/CrossOriginResourceSharingHandler.class.st b/source/Stargate-Model/CrossOriginResourceSharingHandler.class.st index 9f526a7..c5566b8 100644 --- a/source/Stargate-Model/CrossOriginResourceSharingHandler.class.st +++ b/source/Stargate-Model/CrossOriginResourceSharingHandler.class.st @@ -1,15 +1,13 @@ Class { - #name : 'CrossOriginResourceSharingHandler', - #superclass : 'Object', + #name : #CrossOriginResourceSharingHandler, + #superclass : #Object, #classVars : [ 'Headers' ], - #category : 'Stargate-Model-CORS', - #package : 'Stargate-Model', - #tag : 'CORS' + #category : 'Stargate-Model-CORS' } -{ #category : 'class initialization' } +{ #category : #'class initialization' } CrossOriginResourceSharingHandler class >> initialize [ @@ -30,19 +28,19 @@ CrossOriginResourceSharingHandler class >> initialize [ to: 'Access-Control-Expose-Headers' ] -{ #category : 'accessing' } +{ #category : #accessing } CrossOriginResourceSharingHandler >> headerNames [ ^ Headers ] -{ #category : 'private - evaluating' } +{ #category : #'private - evaluating' } CrossOriginResourceSharingHandler >> set: anOrigin asAllowOriginOn: aResponse [ aResponse headers at: self headerNames >> #accessControlAllowOrigin put: anOrigin asString ] -{ #category : 'private - evaluating' } +{ #category : #'private - evaluating' } CrossOriginResourceSharingHandler >> setAnyOriginAllowedOn: aResponse [ aResponse headers at: self headerNames >> #accessControlAllowOrigin put: '*' diff --git a/source/Stargate-Model/CrossOriginResourceSharingPreflightHandler.class.st b/source/Stargate-Model/CrossOriginResourceSharingPreflightHandler.class.st index 95e05cd..99ea493 100644 --- a/source/Stargate-Model/CrossOriginResourceSharingPreflightHandler.class.st +++ b/source/Stargate-Model/CrossOriginResourceSharingPreflightHandler.class.st @@ -2,25 +2,23 @@ I'm a before filter handler for the preflight request. " Class { - #name : 'CrossOriginResourceSharingPreflightHandler', - #superclass : 'CrossOriginResourceSharingHandler', + #name : #CrossOriginResourceSharingPreflightHandler, + #superclass : #CrossOriginResourceSharingHandler, #instVars : [ 'allowOriginPolicy', 'allowedMethodsByRoute', 'optionalHeaderCommands' ], - #category : 'Stargate-Model-CORS', - #package : 'Stargate-Model', - #tag : 'CORS' + #category : 'Stargate-Model-CORS' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } CrossOriginResourceSharingPreflightHandler class >> allowing: anAllowOriginPolicy accessTo: allowMethods applying: headersCommands [ ^ self new initializeAllowing: anAllowOriginPolicy accessTo: allowMethods applying: headersCommands ] -{ #category : 'initialization' } +{ #category : #initialization } CrossOriginResourceSharingPreflightHandler >> initializeAllowing: anAllowOriginPolicy accessTo: methods applying: aCommandCollection [ allowOriginPolicy := anAllowOriginPolicy. @@ -28,7 +26,7 @@ CrossOriginResourceSharingPreflightHandler >> initializeAllowing: anAllowOriginP optionalHeaderCommands := aCommandCollection. ] -{ #category : 'private - evaluating' } +{ #category : #'private - evaluating' } CrossOriginResourceSharingPreflightHandler >> setAllowedHeadersOn: aResponse from: aRequest [ aRequest headers @@ -43,7 +41,7 @@ CrossOriginResourceSharingPreflightHandler >> setAllowedHeadersOn: aResponse fro ] ] -{ #category : 'private - evaluating' } +{ #category : #'private - evaluating' } CrossOriginResourceSharingPreflightHandler >> setAllowedMethodsOn: aResponse from: allowedMethods [ allowedMethods @@ -51,19 +49,19 @@ CrossOriginResourceSharingPreflightHandler >> setAllowedMethodsOn: aResponse fro [ :method | aResponse headers at: self headerNames >> #accessControlAllowMethods addSeparatedWithComma: method ] ] -{ #category : 'private - evaluating' } +{ #category : #'private - evaluating' } CrossOriginResourceSharingPreflightHandler >> setAllowedOriginOn: aResponse from: aRequest [ allowOriginPolicy applyOn: aResponse for: aRequest using: self ] -{ #category : 'private - evaluating' } +{ #category : #'private - evaluating' } CrossOriginResourceSharingPreflightHandler >> setOptionalHeadersOn: aResponse [ optionalHeaderCommands do: [ :command | command value: aResponse headers value: self headerNames ] ] -{ #category : 'evaluating' } +{ #category : #evaluating } CrossOriginResourceSharingPreflightHandler >> teaEvalActionOnRequest: aRequest [ | response | @@ -80,7 +78,7 @@ CrossOriginResourceSharingPreflightHandler >> teaEvalActionOnRequest: aRequest [ ] ] -{ #category : 'evaluating' } +{ #category : #evaluating } CrossOriginResourceSharingPreflightHandler >> withAllowedMethodsFor: aUrl do: aBlock [ allowedMethodsByRoute keys diff --git a/source/Stargate-Model/CrossOriginResourceSharingPreflightHandlerBuilder.class.st b/source/Stargate-Model/CrossOriginResourceSharingPreflightHandlerBuilder.class.st index 9d09d20..3ebba90 100644 --- a/source/Stargate-Model/CrossOriginResourceSharingPreflightHandlerBuilder.class.st +++ b/source/Stargate-Model/CrossOriginResourceSharingPreflightHandlerBuilder.class.st @@ -2,45 +2,43 @@ I'm a builder for CrossOriginResourceSharingPreflightHandlerBuilder instances. " Class { - #name : 'CrossOriginResourceSharingPreflightHandlerBuilder', - #superclass : 'CrossOriginResourceSharingRequestHandlerBuilder', + #name : #CrossOriginResourceSharingPreflightHandlerBuilder, + #superclass : #CrossOriginResourceSharingRequestHandlerBuilder, #instVars : [ 'allowedMethodsBinding', 'allowOriginPolicyBinding', 'addHeaderCommands' ], - #category : 'Stargate-Model-CORS', - #package : 'Stargate-Model', - #tag : 'CORS' + #category : 'Stargate-Model-CORS' } -{ #category : 'configuring' } +{ #category : #configuring } CrossOriginResourceSharingPreflightHandlerBuilder >> allowAnyOrigin [ allowOriginPolicyBinding := Binding to: AllowAnyOriginPolicy new. ] -{ #category : 'configuring' } +{ #category : #configuring } CrossOriginResourceSharingPreflightHandlerBuilder >> allowCredentials [ addHeaderCommands add: [ :headers :headerNames | headers at: headerNames >> #accessControlAllowCredentials put: true asString ] ] -{ #category : 'configuring' } +{ #category : #configuring } CrossOriginResourceSharingPreflightHandlerBuilder >> allowMethods: methods [ allowedMethodsBinding := Binding to: methods ] -{ #category : 'configuring' } +{ #category : #configuring } CrossOriginResourceSharingPreflightHandlerBuilder >> allowOnlyFrom: origins [ allowOriginPolicyBinding := Binding to: ( AllowSpecifiedOriginsPolicy onlyFrom: origins ) ] -{ #category : 'building' } +{ #category : #building } CrossOriginResourceSharingPreflightHandlerBuilder >> build [ ^ CrossOriginResourceSharingPreflightHandler @@ -49,14 +47,14 @@ CrossOriginResourceSharingPreflightHandlerBuilder >> build [ applying: addHeaderCommands ] -{ #category : 'configuring' } +{ #category : #configuring } CrossOriginResourceSharingPreflightHandlerBuilder >> doNotCache [ addHeaderCommands add: [ :headers :headerNames | headers at: headerNames >> #accessControlMaxAge put: -1 asString ] ] -{ #category : 'configuring' } +{ #category : #configuring } CrossOriginResourceSharingPreflightHandlerBuilder >> expireIn: aDuration [ addHeaderCommands @@ -64,7 +62,7 @@ CrossOriginResourceSharingPreflightHandlerBuilder >> expireIn: aDuration [ [ :headers :headerNames | headers at: headerNames >> #accessControlMaxAge put: aDuration asSeconds asString ] ] -{ #category : 'configuring' } +{ #category : #configuring } CrossOriginResourceSharingPreflightHandlerBuilder >> expose: exposedHeaders [ addHeaderCommands @@ -75,7 +73,7 @@ CrossOriginResourceSharingPreflightHandlerBuilder >> expose: exposedHeaders [ ] ] -{ #category : 'initialization' } +{ #category : #initialization } CrossOriginResourceSharingPreflightHandlerBuilder >> initialize [ super initialize. diff --git a/source/Stargate-Model/CrossOriginResourceSharingRequestHandlerBuilder.class.st b/source/Stargate-Model/CrossOriginResourceSharingRequestHandlerBuilder.class.st index 6299c1e..4ccc3ba 100644 --- a/source/Stargate-Model/CrossOriginResourceSharingRequestHandlerBuilder.class.st +++ b/source/Stargate-Model/CrossOriginResourceSharingRequestHandlerBuilder.class.st @@ -1,12 +1,10 @@ Class { - #name : 'CrossOriginResourceSharingRequestHandlerBuilder', - #superclass : 'Object', - #category : 'Stargate-Model-CORS', - #package : 'Stargate-Model', - #tag : 'CORS' + #name : #CrossOriginResourceSharingRequestHandlerBuilder, + #superclass : #Object, + #category : 'Stargate-Model-CORS' } -{ #category : 'building' } +{ #category : #building } CrossOriginResourceSharingRequestHandlerBuilder >> build [ ^ self subclassResponsibility diff --git a/source/Stargate-Model/EntityTagHasher.class.st b/source/Stargate-Model/EntityTagHasher.class.st index 84ae04e..d93beb2 100644 --- a/source/Stargate-Model/EntityTagHasher.class.st +++ b/source/Stargate-Model/EntityTagHasher.class.st @@ -2,17 +2,15 @@ I'm responsible for generating a valid ETag hashing the objects included " Class { - #name : 'EntityTagHasher', - #superclass : 'Object', + #name : #EntityTagHasher, + #superclass : #Object, #instVars : [ 'toHash' ], - #category : 'Stargate-Model-Controllers', - #package : 'Stargate-Model', - #tag : 'Controllers' + #category : 'Stargate-Model-Controllers' } -{ #category : 'calculating' } +{ #category : #calculating } EntityTagHasher >> calculateHash [ | message | @@ -24,13 +22,13 @@ EntityTagHasher >> calculateHash [ ^ MessageDigestAlgorithm sha1 digestStringAsHexString: message ] -{ #category : 'configuring' } +{ #category : #configuring } EntityTagHasher >> include: anObjectToHash [ toHash add: anObjectToHash ] -{ #category : 'initialization' } +{ #category : #initialization } EntityTagHasher >> initialize [ super initialize. diff --git a/source/Stargate-Model/HTTPBasedRESTfulAPI.class.st b/source/Stargate-Model/HTTPBasedRESTfulAPI.class.st index 9b5b689..e46d63d 100644 --- a/source/Stargate-Model/HTTPBasedRESTfulAPI.class.st +++ b/source/Stargate-Model/HTTPBasedRESTfulAPI.class.st @@ -2,8 +2,8 @@ I represent an HTTP based RESTful API, serving one or more services. " Class { - #name : 'HTTPBasedRESTfulAPI', - #superclass : 'Object', + #name : #HTTPBasedRESTfulAPI, + #superclass : #Object, #instVars : [ 'teapotServer', 'controllers', @@ -13,28 +13,23 @@ Class { 'disabledOperationalPlugins', 'optionalCORSHandler' ], - #category : 'Stargate-Model-Controllers', - #package : 'Stargate-Model', - #tag : 'Controllers', - #'gs_options' : [ - 'dbTransient' - ] + #category : 'Stargate-Model-Controllers' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } HTTPBasedRESTfulAPI class >> configuredBy: configuration installing: aRESTfulControllerCollection [ AssertionChecker enforce: [ aRESTfulControllerCollection notEmpty ] because: 'An API needs at least to expose one resource'. ^ self new initializeConfiguredBy: configuration installing: aRESTfulControllerCollection ] -{ #category : 'private - configuring' } +{ #category : #'private - configuring' } HTTPBasedRESTfulAPI >> addController: aRESTfulController [ controllers add: aRESTfulController ] -{ #category : 'configuring' } +{ #category : #configuring } HTTPBasedRESTfulAPI >> allowCrossOriginSharingApplying: aConfigurationBlock [ | builder | @@ -46,7 +41,7 @@ HTTPBasedRESTfulAPI >> allowCrossOriginSharingApplying: aConfigurationBlock [ optionalCORSHandler := Optional containing: builder actualRequestHandler ] -{ #category : 'private - configuring' } +{ #category : #'private - configuring' } HTTPBasedRESTfulAPI >> applyCrossSharingResourceConfigurationTo: response accordingTo: request [ optionalCORSHandler withContentDo: [ :handler | @@ -55,7 +50,7 @@ HTTPBasedRESTfulAPI >> applyCrossSharingResourceConfigurationTo: response accord ] ] -{ #category : 'configuring' } +{ #category : #configuring } HTTPBasedRESTfulAPI >> authenticatedBy: anAuthorizationFilter [ teapotServer @@ -63,13 +58,13 @@ HTTPBasedRESTfulAPI >> authenticatedBy: anAuthorizationFilter [ when: [ :request | ( CrossOriginResourceSharingFilter isForPreflight: request ) not ] ] -{ #category : 'private - configuring' } +{ #category : #'private - configuring' } HTTPBasedRESTfulAPI >> configureErrorHandlers [ errorHandlers do: [ :errorHandler | teapotServer exception: errorHandler ] ] -{ #category : 'private - configuring' } +{ #category : #'private - configuring' } HTTPBasedRESTfulAPI >> configureRoutes [ | configurator | @@ -78,7 +73,7 @@ HTTPBasedRESTfulAPI >> configureRoutes [ controllers do: [ :controller | configurator addRoutesOf: controller ] ] -{ #category : 'private - configuring' } +{ #category : #'private - configuring' } HTTPBasedRESTfulAPI >> configureRoutesDeclaredByPlugin: anOperationalPluginType [ | configurator | @@ -88,7 +83,7 @@ HTTPBasedRESTfulAPI >> configureRoutesDeclaredByPlugin: anOperationalPluginType do: [ :controller | configurator addRoutesOf: controller ] ] -{ #category : 'configuring' } +{ #category : #configuring } HTTPBasedRESTfulAPI >> disable: anOperationalPluginType [ enabledOperationalPlugins @@ -107,7 +102,7 @@ HTTPBasedRESTfulAPI >> disable: anOperationalPluginType [ ] ] -{ #category : 'configuring' } +{ #category : #configuring } HTTPBasedRESTfulAPI >> enable: anOperationalPluginType [ disabledOperationalPlugins @@ -126,7 +121,7 @@ HTTPBasedRESTfulAPI >> enable: anOperationalPluginType [ ] ] -{ #category : 'configuring' } +{ #category : #configuring } HTTPBasedRESTfulAPI >> enable: anOperationalPluginEndpoint configuredBy: configuration [ | pluginToEnable | @@ -137,7 +132,7 @@ HTTPBasedRESTfulAPI >> enable: anOperationalPluginEndpoint configuredBy: configu pluginToEnable includeControllersIn: self ] -{ #category : 'initialization' } +{ #category : #initialization } HTTPBasedRESTfulAPI >> initializeConfiguredBy: configuration installing: aRESTfulControllerCollection [ optionalCORSHandler := Optional unusedBecause: 'CORS not configured'. @@ -152,7 +147,7 @@ HTTPBasedRESTfulAPI >> initializeConfiguredBy: configuration installing: aRESTfu initializeEnabledOperationalPlugins ] -{ #category : 'initialization' } +{ #category : #initialization } HTTPBasedRESTfulAPI >> initializeControllersWithAll: aRESTfulControllerCollection [ controllers := OrderedCollection with: @@ -160,7 +155,7 @@ HTTPBasedRESTfulAPI >> initializeControllersWithAll: aRESTfulControllerCollectio controllers addAll: aRESTfulControllerCollection ] -{ #category : 'initialization' } +{ #category : #initialization } HTTPBasedRESTfulAPI >> initializeEnabledOperationalPlugins [ enabledOperationalPlugins := OrderedSet new. @@ -175,7 +170,7 @@ HTTPBasedRESTfulAPI >> initializeEnabledOperationalPlugins [ thenDo: [ :plugin | self enable: plugin endpoint configuredBy: operationsConfiguration ] ] -{ #category : 'initialization' } +{ #category : #initialization } HTTPBasedRESTfulAPI >> initializeErrorHandlers [ errorHandlers := OrderedCollection new. @@ -190,7 +185,7 @@ HTTPBasedRESTfulAPI >> initializeErrorHandlers [ ] ] -{ #category : 'actions' } +{ #category : #actions } HTTPBasedRESTfulAPI >> install [ self @@ -198,13 +193,13 @@ HTTPBasedRESTfulAPI >> install [ configureErrorHandlers ] -{ #category : 'testing' } +{ #category : #testing } HTTPBasedRESTfulAPI >> isEnabled: aPluginType [ ^ enabledOperationalPlugins anySatisfy: [ :plugin | plugin isA: aPluginType ] ] -{ #category : 'private - configuring' } +{ #category : #'private - configuring' } HTTPBasedRESTfulAPI >> markAsDisabled: plugin [ plugin stop. @@ -212,7 +207,7 @@ HTTPBasedRESTfulAPI >> markAsDisabled: plugin [ disabledOperationalPlugins add: plugin ] -{ #category : 'private - configuring' } +{ #category : #'private - configuring' } HTTPBasedRESTfulAPI >> markAsEnabled: plugin [ disabledOperationalPlugins remove: plugin ifAbsent: [ ]. @@ -220,19 +215,19 @@ HTTPBasedRESTfulAPI >> markAsEnabled: plugin [ plugin startOn: teapotServer ] -{ #category : 'configuring' } +{ #category : #configuring } HTTPBasedRESTfulAPI >> on: exception addErrorHandler: aDyadicBlock [ errorHandlers add: exception -> aDyadicBlock ] -{ #category : 'accessing' } +{ #category : #accessing } HTTPBasedRESTfulAPI >> operationsConfiguration [ ^ operationsConfiguration ] -{ #category : 'configuring' } +{ #category : #configuring } HTTPBasedRESTfulAPI >> removeRoutesDeclaredByPlugin: anOperationalPluginType [ ^ self withControllersDefinedByPlugin: anOperationalPluginType do: [ :controller | @@ -241,27 +236,27 @@ HTTPBasedRESTfulAPI >> removeRoutesDeclaredByPlugin: anOperationalPluginType [ ] ] -{ #category : 'actions' } +{ #category : #actions } HTTPBasedRESTfulAPI >> start [ enabledOperationalPlugins do: [ :plugin | plugin startOn: teapotServer ]. teapotServer start ] -{ #category : 'actions' } +{ #category : #actions } HTTPBasedRESTfulAPI >> stop [ teapotServer stop. enabledOperationalPlugins do: #stop ] -{ #category : 'private - configuring' } +{ #category : #'private - configuring' } HTTPBasedRESTfulAPI >> withConfigurationOf: plugin do: aPresentBlock ifAbsent: anAbsentBlock [ ^ operationsConfiguration at: plugin endpoint ifPresent: aPresentBlock ifAbsent: anAbsentBlock ] -{ #category : 'private - configuring' } +{ #category : #'private - configuring' } HTTPBasedRESTfulAPI >> withControllersDefinedByPlugin: anOperationalPluginType do: aBlock [ controllers diff --git a/source/Stargate-Model/HttpRequestContext.class.st b/source/Stargate-Model/HttpRequestContext.class.st index 17a50c3..95d935e 100644 --- a/source/Stargate-Model/HttpRequestContext.class.st +++ b/source/Stargate-Model/HttpRequestContext.class.st @@ -3,20 +3,15 @@ I'm a context that gets created each time an Http Request is proceesed. I can ca I also provide some facilities to manage Hypermedia Controls. " Class { - #name : 'HttpRequestContext', - #superclass : 'Object', + #name : #HttpRequestContext, + #superclass : #Object, #instVars : [ 'knownObjects' ], - #category : 'Stargate-Model-Routing', - #package : 'Stargate-Model', - #tag : 'Routing', - #'gs_options' : [ - 'dbTransient' - ] + #category : 'Stargate-Model-Routing' } -{ #category : 'pagination' } +{ #category : #pagination } HttpRequestContext >> addPaginationLink: aUrl relatedTo: aRelationType [ | controls | @@ -31,14 +26,14 @@ HttpRequestContext >> addPaginationLink: aUrl relatedTo: aRelationType [ build ) ] -{ #category : 'accessing' } +{ #category : #accessing } HttpRequestContext >> hold: anObject under: aConcept [ knownObjects at: aConcept put: anObject. ^ anObject ] -{ #category : 'hypermedia' } +{ #category : #hypermedia } HttpRequestContext >> holdAsHypermediaControls: aControlCollection for: resource [ | resourcesHypermediaControls | @@ -49,7 +44,7 @@ HttpRequestContext >> holdAsHypermediaControls: aControlCollection for: resource resourcesHypermediaControls at: resource put: aControlCollection ] -{ #category : 'hypermedia' } +{ #category : #hypermedia } HttpRequestContext >> hypermediaControlsFor: resource [ | hypermediaControls | @@ -58,20 +53,20 @@ HttpRequestContext >> hypermediaControlsFor: resource [ ^ hypermediaControls at: resource ifAbsent: [ #() ] ] -{ #category : 'authorization' } +{ #category : #authorization } HttpRequestContext >> includesPermission: aPermission [ ^ ( self objectUnder: #permissions ifNone: [ #() ] ) includes: aPermission ] -{ #category : 'initialization' } +{ #category : #initialization } HttpRequestContext >> initialize [ super initialize. knownObjects := IdentityDictionary new ] -{ #category : 'accessing' } +{ #category : #accessing } HttpRequestContext >> objectUnder: aConcept [ ^ self objectUnder: aConcept ifNone: [ @@ -80,61 +75,61 @@ HttpRequestContext >> objectUnder: aConcept [ aConcept asString) ] ] -{ #category : 'accessing' } +{ #category : #accessing } HttpRequestContext >> objectUnder: aConcept ifNone: aBlock [ ^ knownObjects at: aConcept ifAbsent: aBlock ] -{ #category : 'pagination' } +{ #category : #pagination } HttpRequestContext >> paginationControls [ ^ (self objectUnder: #paginationLinks ifNone: [ #() ]) asArray ] -{ #category : 'accessing' } +{ #category : #accessing } HttpRequestContext >> parentResource [ ^ self objectUnder: #parentResource ] -{ #category : 'accessing' } +{ #category : #accessing } HttpRequestContext >> parentResource: anIdentifier [ self hold: anIdentifier under: #parentResource ] -{ #category : 'authorization' } +{ #category : #authorization } HttpRequestContext >> permissions: aPermissionCollection [ self hold: aPermissionCollection under: #permissions ] -{ #category : 'accessing' } +{ #category : #accessing } HttpRequestContext >> targetLanguageTag [ ^ self objectUnder: #targetLanguageTag ] -{ #category : 'accessing' } +{ #category : #accessing } HttpRequestContext >> targetLanguageTag: aLanguageTag [ ^ self hold: aLanguageTag under: #targetLanguageTag ] -{ #category : 'accessing' } +{ #category : #accessing } HttpRequestContext >> targetMediaType [ ^ self objectUnder: #targetMediaType ] -{ #category : 'accessing' } +{ #category : #accessing } HttpRequestContext >> targetMediaType: aMediaType [ ^ self hold: aMediaType under: #targetMediaType ] -{ #category : 'accessing' } +{ #category : #accessing } HttpRequestContext >> withTargetLanguageTagDo: aBlock [ knownObjects at: #targetLanguageTag ifPresent: aBlock diff --git a/source/Stargate-Model/HypermediaDrivenRESTfulRequestHandler.class.st b/source/Stargate-Model/HypermediaDrivenRESTfulRequestHandler.class.st index 929e616..541eabf 100644 --- a/source/Stargate-Model/HypermediaDrivenRESTfulRequestHandler.class.st +++ b/source/Stargate-Model/HypermediaDrivenRESTfulRequestHandler.class.st @@ -2,17 +2,15 @@ I represent a RESTful handler supporting hypermedia driven controllers. " Class { - #name : 'HypermediaDrivenRESTfulRequestHandler', - #superclass : 'RESTfulRequestHandlerBehavior', + #name : #HypermediaDrivenRESTfulRequestHandler, + #superclass : #RESTfulRequestHandlerBehavior, #instVars : [ 'mediaControlsFactory' ], - #category : 'Stargate-Model-HATEOAS', - #package : 'Stargate-Model', - #tag : 'HATEOAS' + #category : 'Stargate-Model-HATEOAS' } -{ #category : 'encoding' } +{ #category : #encoding } HypermediaDrivenRESTfulRequestHandler class >> encode: resource toJsonUsing: writer as: schema within: requestContext [ writer @@ -28,7 +26,7 @@ HypermediaDrivenRESTfulRequestHandler class >> encode: resource toJsonUsing: wri inWhichCase: [ writer nextPut: resource ] ] -{ #category : 'encoding' } +{ #category : #encoding } HypermediaDrivenRESTfulRequestHandler class >> encode: resource toJsonUsing: writer within: requestContext [ writer for: ResourceCollection do: [ :mapping | @@ -41,7 +39,7 @@ HypermediaDrivenRESTfulRequestHandler class >> encode: resource toJsonUsing: wri writer nextPut: resource ] -{ #category : 'instance creation' } +{ #category : #'instance creation' } HypermediaDrivenRESTfulRequestHandler class >> resourceLocator: aResouceLocator paginationPolicy: aPaginationPolicy decodingRules: theDecodingRules encodingRules: theEncodingRules calculateEntityTagsWith: entityTagCalculator cachingDirectives: theCachingDirectives allowedLanguageTags: allowedLanguageTags drivenBy: aMediaControlsFactory handleErrorsWith: anExceptionHandler [ ^ self new @@ -56,14 +54,14 @@ HypermediaDrivenRESTfulRequestHandler class >> resourceLocator: aResouceLocator handleErrorsWith: anExceptionHandler ] -{ #category : 'private' } +{ #category : #private } HypermediaDrivenRESTfulRequestHandler >> encodeResource: resource as: mediaType within: requestContext [ self holdResource: resource controlsWithin: requestContext. ^ super encodeResource: resource as: mediaType within: requestContext ] -{ #category : 'private' } +{ #category : #private } HypermediaDrivenRESTfulRequestHandler >> encodeResourceCollection: resourceCollection basedOn: httpRequest within: requestContext [ requestContext @@ -78,7 +76,7 @@ HypermediaDrivenRESTfulRequestHandler >> encodeResourceCollection: resourceColle within: requestContext ] -{ #category : 'private' } +{ #category : #private } HypermediaDrivenRESTfulRequestHandler >> holdResource: resource controlsWithin: requestContext [ requestContext @@ -86,7 +84,7 @@ HypermediaDrivenRESTfulRequestHandler >> holdResource: resource controlsWithin: for: resource ] -{ #category : 'initialization' } +{ #category : #initialization } HypermediaDrivenRESTfulRequestHandler >> initializeResourceLocator: aResouceLocator paginationPolicy: aPaginationPolicy decodingRules: theDecodingRules @@ -111,7 +109,7 @@ HypermediaDrivenRESTfulRequestHandler >> initializeResourceLocator: aResouceLoca mediaControlsFactory := aMediaControlsFactory ] -{ #category : 'private' } +{ #category : #private } HypermediaDrivenRESTfulRequestHandler >> mediaControlsFor: resource within: requestContext [ ^ mediaControlsFactory diff --git a/source/Stargate-Model/JWTBearerAuthenticationFilter.class.st b/source/Stargate-Model/JWTBearerAuthenticationFilter.class.st index 0a26890..8a06f6a 100644 --- a/source/Stargate-Model/JWTBearerAuthenticationFilter.class.st +++ b/source/Stargate-Model/JWTBearerAuthenticationFilter.class.st @@ -2,18 +2,16 @@ I'm an authentication filter using Bearer tokens in JWT format " Class { - #name : 'JWTBearerAuthenticationFilter', - #superclass : 'AuthenticationFilter', + #name : #JWTBearerAuthenticationFilter, + #superclass : #AuthenticationFilter, #instVars : [ 'key', 'algorithm' ], - #category : 'Stargate-Model-Auth', - #package : 'Stargate-Model', - #tag : 'Auth' + #category : 'Stargate-Model-Auth' } -{ #category : 'private' } +{ #category : #private } JWTBearerAuthenticationFilter class >> canHandle: configuration [ | schema algorithm | @@ -24,7 +22,7 @@ JWTBearerAuthenticationFilter class >> canHandle: configuration [ JsonWebAlgorithm supportsAlgorithmNamed: algorithm ] ] ] -{ #category : 'private' } +{ #category : #private } JWTBearerAuthenticationFilter class >> configuredBy: configuration [ ^ self @@ -32,19 +30,19 @@ JWTBearerAuthenticationFilter class >> configuredBy: configuration [ forAlgorithmNamed: ( configuration at: #authAlgorithm ) ] -{ #category : 'instance creation' } +{ #category : #'instance creation' } JWTBearerAuthenticationFilter class >> with: aKey forAlgorithmNamed: anAlgorithmName [ ^ self new initializeWith: aKey forAlgorithm: ( JsonWebAlgorithm named: anAlgorithmName ) ] -{ #category : 'accessing' } +{ #category : #accessing } JWTBearerAuthenticationFilter >> authChallenge [ ^ 'Bearer' ] -{ #category : 'private' } +{ #category : #private } JWTBearerAuthenticationFilter >> checkCredentials: authorization for: httpRequest within: requestContext ifInvalid: aBlock [ | tokenString | @@ -63,7 +61,7 @@ JWTBearerAuthenticationFilter >> checkCredentials: authorization for: httpReques do: [ :error | error return: aBlock value ] ] -{ #category : 'initialization' } +{ #category : #initialization } JWTBearerAuthenticationFilter >> initializeWith: aKey forAlgorithm: anAlgorithm [ key := aKey . diff --git a/source/Stargate-Model/MediaControlsBuilder.class.st b/source/Stargate-Model/MediaControlsBuilder.class.st index ce7dcea..7a0b288 100644 --- a/source/Stargate-Model/MediaControlsBuilder.class.st +++ b/source/Stargate-Model/MediaControlsBuilder.class.st @@ -2,48 +2,46 @@ I'm a builder easing the creation of media controls " Class { - #name : 'MediaControlsBuilder', - #superclass : 'Object', + #name : #MediaControlsBuilder, + #superclass : #Object, #instVars : [ 'mediaControls', 'resourceLocatorBinding' ], - #category : 'Stargate-Model-HATEOAS', - #package : 'Stargate-Model', - #tag : 'HATEOAS' + #category : 'Stargate-Model-HATEOAS' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } MediaControlsBuilder class >> locatingResourcesWith: aResourceLocator [ ^ self new initializeLocatingResourcesWith: aResourceLocator ] -{ #category : 'adding' } +{ #category : #adding } MediaControlsBuilder >> addAsSelfLink: aUrl [ ^ self addLink: aUrl relatedTo: 'self' ] -{ #category : 'adding' } +{ #category : #adding } MediaControlsBuilder >> addLink: aUrl relatedTo: aRelationType [ mediaControls add: ( aUrl asWebLink relationType: aRelationType ) ] -{ #category : 'adding' } +{ #category : #adding } MediaControlsBuilder >> addRelativeLink: aRelativeUrl relatedTo: aRelationType [ self addLink: resourceLocatorBinding content baseUrl / aRelativeUrl relatedTo: aRelationType ] -{ #category : 'building' } +{ #category : #building } MediaControlsBuilder >> build [ ^ mediaControls asArray ] -{ #category : 'initialization' } +{ #category : #initialization } MediaControlsBuilder >> initialize [ super initialize. @@ -51,7 +49,7 @@ MediaControlsBuilder >> initialize [ resourceLocatorBinding := Binding undefinedExplainedBy: 'Missing resource locator' ] -{ #category : 'initialization' } +{ #category : #initialization } MediaControlsBuilder >> initializeLocatingResourcesWith: aResourceLocator [ resourceLocatorBinding := Binding to: aResourceLocator diff --git a/source/Stargate-Model/NeoJSONWriter.extension.st b/source/Stargate-Model/NeoJSONWriter.extension.st deleted file mode 100644 index 745b9ee..0000000 --- a/source/Stargate-Model/NeoJSONWriter.extension.st +++ /dev/null @@ -1,35 +0,0 @@ -Extension { #name : #NeoJSONWriter } - -{ #category : #'*Stargate-Model' } -NeoJSONWriter >> mapZincEvent [ - - self for: ZnHeaders customDo: [ :mapping | - mapping writer: [ :jsonWriter :headers | - jsonWriter writeMap: headers ] ]. - self for: ZnRequest do: [ :mapper | - mapper - mapAccessor: #method; - mapProperty: #uri getter: [ :request | request uri printString ]; - mapProperty: #body getter: [ :request | request contents ]; - mapAccessor: #headers ]. - self for: ZnResponse do: [ :mapper | - mapper - mapAccessor: #code; - mapProperty: #totalSize - getter: [ :response | response contentLength ]; - mapProperty: #content getter: [ :response | - (response hasEntity and: [ response entity hasContentType ]) - then: [ response contents asString copyNoMoreThanFirst: 4000 ] - otherwise: [ nil ] ]; - mapAccessor: #headers ]. - - { - ZnServerTransactionEvent. - ZnSimplifiedServerTransactionEvent. - ZnClientTransactionEvent } do: [ :event | - self for: event do: [ :mapper | - mapper - mapProperty: #summary getter: [ :thisEvent | thisEvent printString ]; - mapAccessor: #request; - mapAccessor: #response ] ] -] diff --git a/source/Stargate-Model/OperationalPlugin.class.st b/source/Stargate-Model/OperationalPlugin.class.st index aa40753..c31d7e5 100644 --- a/source/Stargate-Model/OperationalPlugin.class.st +++ b/source/Stargate-Model/OperationalPlugin.class.st @@ -13,44 +13,42 @@ An operational plugin must have the following characteristics: " Class { - #name : 'OperationalPlugin', - #superclass : 'Object', - #category : 'Stargate-Model-Operations', - #package : 'Stargate-Model', - #tag : 'Operations' + #name : #OperationalPlugin, + #superclass : #Object, + #category : 'Stargate-Model-Operations' } -{ #category : 'accessing' } +{ #category : #accessing } OperationalPlugin class >> availablePlugins [ ^ self allLeafSubclasses ] -{ #category : 'configuring' } +{ #category : #configuring } OperationalPlugin class >> configureMediaControlsIn: builder within: requestContext [ self subclassResponsibility ] -{ #category : 'instance creation' } +{ #category : #'instance creation' } OperationalPlugin class >> configuredBy: configuration [ ^ self subclassResponsibility ] -{ #category : 'testing' } +{ #category : #testing } OperationalPlugin class >> enabledByDefault [ ^ false ] -{ #category : 'accessing' } +{ #category : #accessing } OperationalPlugin class >> endpoint [ ^ self subclassResponsibility ] -{ #category : 'accessing' } +{ #category : #accessing } OperationalPlugin class >> pluginAt: endpoint [ ^ self availablePlugins @@ -58,7 +56,7 @@ OperationalPlugin class >> pluginAt: endpoint [ ifNone: [ ObjectNotFound signal: ( 'Plugin <1s> not available' expandMacrosWith: endpoint ) ] ] -{ #category : 'instance creation' } +{ #category : #'instance creation' } OperationalPlugin class >> pluginConfigurationOn: configuration [ | selfConfiguration | @@ -72,37 +70,37 @@ OperationalPlugin class >> pluginConfigurationOn: configuration [ ^ selfConfiguration ] -{ #category : 'accessing' } +{ #category : #accessing } OperationalPlugin class >> pluginName [ ^ self subclassResponsibility ] -{ #category : 'accessing' } +{ #category : #accessing } OperationalPlugin >> endpoint [ ^ self class endpoint ] -{ #category : 'configuring' } +{ #category : #configuring } OperationalPlugin >> includeControllersIn: api [ self subclassResponsibility ] -{ #category : 'accessing' } +{ #category : #accessing } OperationalPlugin >> name [ ^ self class pluginName ] -{ #category : 'printing' } +{ #category : #printing } OperationalPlugin >> printOn: stream [ stream nextPutAll: self name ] -{ #category : 'controlling' } +{ #category : #controlling } OperationalPlugin >> startOn: teapotServer [ "This method is called when the server is started, giving @@ -111,7 +109,7 @@ OperationalPlugin >> startOn: teapotServer [ ] -{ #category : 'controlling' } +{ #category : #controlling } OperationalPlugin >> stop [ "This method is called when the server is stopped, giving diff --git a/source/Stargate-Model/OperationalPluginsRESTfulController.class.st b/source/Stargate-Model/OperationalPluginsRESTfulController.class.st index 3e372cd..4e6ea43 100644 --- a/source/Stargate-Model/OperationalPluginsRESTfulController.class.st +++ b/source/Stargate-Model/OperationalPluginsRESTfulController.class.st @@ -2,25 +2,23 @@ I'm a RESTful controller providing access to the list of available operational plugins and its endpoints " Class { - #name : 'OperationalPluginsRESTfulController', - #superclass : 'OperationsRESTfulController', + #name : #OperationalPluginsRESTfulController, + #superclass : #OperationsRESTfulController, #instVars : [ 'requestHandler', 'api' ], - #category : 'Stargate-Model-Operations', - #package : 'Stargate-Model', - #tag : 'Operations' + #category : 'Stargate-Model-Operations' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } OperationalPluginsRESTfulController class >> on: anHTTPBasedRESTfulAPI [ ^ ( self authenticationFilterBasedOn: anHTTPBasedRESTfulAPI operationsConfiguration ) initializeOn: anHTTPBasedRESTfulAPI ] -{ #category : 'API' } +{ #category : #API } OperationalPluginsRESTfulController >> changeOperationalPluginStatusBasedOn: httpRequest within: requestContext [ self assert: httpRequest isAuthorizedTo: self updatePermission within: requestContext. @@ -40,7 +38,7 @@ OperationalPluginsRESTfulController >> changeOperationalPluginStatusBasedOn: htt ] ] -{ #category : 'private' } +{ #category : #private } OperationalPluginsRESTfulController >> configureOperationalPluginEncodingOn: writer within: requestContext [ OperationalPlugin availablePlugins @@ -56,7 +54,7 @@ OperationalPluginsRESTfulController >> configureOperationalPluginEncodingOn: wri ] ] -{ #category : 'routes' } +{ #category : #routes } OperationalPluginsRESTfulController >> declareGetOperationalPluginRoute [ ^ RouteSpecification @@ -65,7 +63,7 @@ OperationalPluginsRESTfulController >> declareGetOperationalPluginRoute [ evaluating: [ :httpRequest :requestContext | self operationalPluginBasedOn: httpRequest within: requestContext ] ] -{ #category : 'routes' } +{ #category : #routes } OperationalPluginsRESTfulController >> declareGetOperationalPluginsRoute [ ^ RouteSpecification @@ -75,7 +73,7 @@ OperationalPluginsRESTfulController >> declareGetOperationalPluginsRoute [ [ :httpRequest :requestContext | self operationalPluginsBasedOn: httpRequest within: requestContext ] ] -{ #category : 'routes' } +{ #category : #routes } OperationalPluginsRESTfulController >> declareUpdateOperationalPluginRoute [ ^ RouteSpecification handling: #PATCH @@ -84,14 +82,14 @@ OperationalPluginsRESTfulController >> declareUpdateOperationalPluginRoute [ self changeOperationalPluginStatusBasedOn: httpRequest within: requestContext ] ] -{ #category : 'initialization' } +{ #category : #initialization } OperationalPluginsRESTfulController >> initializeOn: anHTTPBasedRESTfulAPI [ api := anHTTPBasedRESTfulAPI. self initializeRequestHandler ] -{ #category : 'initialization' } +{ #category : #initialization } OperationalPluginsRESTfulController >> initializeRequestHandler [ requestHandler := RESTfulRequestHandlerBuilder new @@ -114,7 +112,7 @@ OperationalPluginsRESTfulController >> initializeRequestHandler [ build ] -{ #category : 'API' } +{ #category : #API } OperationalPluginsRESTfulController >> operationalPluginBasedOn: httpRequest within: requestContext [ self assert: httpRequest isAuthorizedWithin: requestContext. @@ -125,13 +123,13 @@ OperationalPluginsRESTfulController >> operationalPluginBasedOn: httpRequest wit get: [ :endpoint | OperationalPlugin pluginAt: endpoint ] ] -{ #category : 'private' } +{ #category : #private } OperationalPluginsRESTfulController >> operationalPluginVersion1dot0dot0MediaType [ ^ self jsonMediaType: 'operational-plugin' vendoredBy: 'stargate' version: '1.0.0' ] -{ #category : 'API' } +{ #category : #API } OperationalPluginsRESTfulController >> operationalPluginsBasedOn: httpRequest within: requestContext [ self assert: httpRequest isAuthorizedWithin: requestContext. @@ -142,25 +140,25 @@ OperationalPluginsRESTfulController >> operationalPluginsBasedOn: httpRequest wi getCollection: [ OperationalPlugin availablePlugins ] ] -{ #category : 'private' } +{ #category : #private } OperationalPluginsRESTfulController >> requestHandler [ ^ requestHandler ] -{ #category : 'private' } +{ #category : #private } OperationalPluginsRESTfulController >> requiredPermission [ ^ 'read:operations' ] -{ #category : 'querying' } +{ #category : #querying } OperationalPluginsRESTfulController >> statusOf: aPluginType [ ^ ( api isEnabled: aPluginType ) then: [ 'ENABLED' ] otherwise: [ 'DISABLED' ] ] -{ #category : 'private' } +{ #category : #private } OperationalPluginsRESTfulController >> updatePermission [ ^ 'update:operations' diff --git a/source/Stargate-Model/OperationsRESTfulController.class.st b/source/Stargate-Model/OperationsRESTfulController.class.st index 598b070..4b8d823 100644 --- a/source/Stargate-Model/OperationsRESTfulController.class.st +++ b/source/Stargate-Model/OperationsRESTfulController.class.st @@ -2,55 +2,53 @@ I'm an abstract class providing behavior for all the RESTful controllers related to operations and operation plugins. " Class { - #name : 'OperationsRESTfulController', - #superclass : 'SingleResourceRESTfulController', + #name : #OperationsRESTfulController, + #superclass : #SingleResourceRESTfulController, #instVars : [ 'authenticationFilter' ], - #category : 'Stargate-Model-Operations', - #package : 'Stargate-Model', - #tag : 'Operations' + #category : 'Stargate-Model-Operations' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } OperationsRESTfulController class >> authenticationFilterBasedOn: configuration [ ^ self new initializeAuthenticationFilterBasedOn: configuration ] -{ #category : 'testing' } +{ #category : #testing } OperationsRESTfulController class >> isAbstract [ ^ self = OperationsRESTfulController ] -{ #category : 'private' } +{ #category : #private } OperationsRESTfulController >> assert: httpRequest isAuthorizedWithin: requestContext [ self assert: httpRequest isAuthorizedTo: self requiredPermission within: requestContext ] -{ #category : 'initialization' } +{ #category : #initialization } OperationsRESTfulController >> initializeAuthenticationFilterBasedOn: configuration [ authenticationFilter := AuthenticationFilter basedOn: configuration ] -{ #category : 'private' } +{ #category : #private } OperationsRESTfulController >> requiredPermission [ ^ self subclassResponsibility ] -{ #category : 'accessing' } +{ #category : #accessing } OperationsRESTfulController >> routes [ ^ super routes collect: [ :routeSpecification | routeSpecification authenticatedBy: authenticationFilter ] ] -{ #category : 'private' } +{ #category : #private } OperationsRESTfulController >> typeIdConstraint [ ^ IsObject diff --git a/source/Stargate-Model/PaginationSpecification.class.st b/source/Stargate-Model/PaginationSpecification.class.st index e8ea1f9..a7c88cb 100644 --- a/source/Stargate-Model/PaginationSpecification.class.st +++ b/source/Stargate-Model/PaginationSpecification.class.st @@ -2,18 +2,16 @@ I'm a pagination specification, used to know the start index and the expected page size " Class { - #name : 'PaginationSpecification', - #superclass : 'Object', + #name : #PaginationSpecification, + #superclass : #Object, #instVars : [ 'start', 'limit' ], - #category : 'Stargate-Model-Pagination', - #package : 'Stargate-Model', - #tag : 'Pagination' + #category : 'Stargate-Model-Pagination' } -{ #category : 'Instance creation' } +{ #category : #'Instance creation' } PaginationSpecification class >> startingAt: aNumber limitedTo: aLimit [ AssertionChecker @@ -23,26 +21,26 @@ PaginationSpecification class >> startingAt: aNumber limitedTo: aLimit [ ^ self new initializeStartingAt: ( aNumber max: 1 ) limitedTo: aLimit ] -{ #category : 'accessing' } +{ #category : #accessing } PaginationSpecification >> end [ ^ start + limit - 1 ] -{ #category : 'initialize - release' } +{ #category : #'initialize - release' } PaginationSpecification >> initializeStartingAt: anStartIndex limitedTo: aLimitCount [ start := anStartIndex. limit := aLimitCount ] -{ #category : 'accessing' } +{ #category : #accessing } PaginationSpecification >> limit [ ^ limit ] -{ #category : 'printing' } +{ #category : #printing } PaginationSpecification >> printOn: aStream [ aStream @@ -53,7 +51,7 @@ PaginationSpecification >> printOn: aStream [ print: limit ] -{ #category : 'accessing' } +{ #category : #accessing } PaginationSpecification >> start [ ^ start diff --git a/source/Stargate-Model/QualifiedLanguageRange.class.st b/source/Stargate-Model/QualifiedLanguageRange.class.st index a2b7b10..e37f5dc 100644 --- a/source/Stargate-Model/QualifiedLanguageRange.class.st +++ b/source/Stargate-Model/QualifiedLanguageRange.class.st @@ -2,18 +2,16 @@ I'm a language range including a quality parameter as used in Accept-Language headers " Class { - #name : 'QualifiedLanguageRange', - #superclass : 'Object', + #name : #QualifiedLanguageRange, + #superclass : #Object, #instVars : [ 'languangeRange', 'quality' ], - #category : 'Stargate-Model-Controllers', - #package : 'Stargate-Model', - #tag : 'Controllers' + #category : 'Stargate-Model-Controllers' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } QualifiedLanguageRange class >> fromString: aString [ ^ ( aString substrings: ';' ) @@ -35,26 +33,26 @@ QualifiedLanguageRange class >> fromString: aString [ ] ] -{ #category : 'instance creation' } +{ #category : #'instance creation' } QualifiedLanguageRange class >> qualifying: aLanguageRange with: aQualityFactor [ ^ self new initializeQualifying: aLanguageRange with: aQualityFactor ] -{ #category : 'initialization' } +{ #category : #initialization } QualifiedLanguageRange >> initializeQualifying: aLanguageRange with: aQualityFactor [ languangeRange := aLanguageRange. quality := aQualityFactor ] -{ #category : 'accessing' } +{ #category : #accessing } QualifiedLanguageRange >> quality [ ^ quality ] -{ #category : 'accessing' } +{ #category : #accessing } QualifiedLanguageRange >> range [ ^ languangeRange diff --git a/source/Stargate-Model/RESTfulControllerAcceptNegotiator.class.st b/source/Stargate-Model/RESTfulControllerAcceptNegotiator.class.st index 0fb3eab..6ac591d 100644 --- a/source/Stargate-Model/RESTfulControllerAcceptNegotiator.class.st +++ b/source/Stargate-Model/RESTfulControllerAcceptNegotiator.class.st @@ -2,30 +2,28 @@ I will provide the best representation (media type) to use for processing an HTTP Request given an available media type list " Class { - #name : 'RESTfulControllerAcceptNegotiator', - #superclass : 'Object', + #name : #RESTfulControllerAcceptNegotiator, + #superclass : #Object, #instVars : [ 'availableMediaTypes', 'availableLanguageTags' ], - #category : 'Stargate-Model-Controllers', - #package : 'Stargate-Model', - #tag : 'Controllers' + #category : 'Stargate-Model-Controllers' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } RESTfulControllerAcceptNegotiator class >> accepting: aMediaTypeCollection [ ^ self accepting: aMediaTypeCollection inAnyOf: #() ] -{ #category : 'instance creation' } +{ #category : #'instance creation' } RESTfulControllerAcceptNegotiator class >> accepting: aMediaTypeCollection inAnyOf: aLanguageTagCollection [ ^ self new initializeAccepting: aMediaTypeCollection inAnyOf: aLanguageTagCollection ] -{ #category : 'private - accessing' } +{ #category : #'private - accessing' } RESTfulControllerAcceptNegotiator >> acceptableMediaTypesIn: anHttpRequest [ | acceptHeaderContent | @@ -40,7 +38,7 @@ RESTfulControllerAcceptNegotiator >> acceptableMediaTypesIn: anHttpRequest [ otherwise: [ self splitMediaTypesIn: acceptHeaderContent ] ] -{ #category : 'private - accessing' } +{ #category : #'private - accessing' } RESTfulControllerAcceptNegotiator >> acceptableQualifiedLanguageRangesIn: anHttpRequest [ | acceptHeaderContent | @@ -57,7 +55,7 @@ RESTfulControllerAcceptNegotiator >> acceptableQualifiedLanguageRangesIn: anHttp otherwise: [ self splitQualifiedLanguageRangesIn: acceptHeaderContent ] ] -{ #category : 'querying' } +{ #category : #querying } RESTfulControllerAcceptNegotiator >> bestLanguageFor: anHttpRequest [ "This method returns the best suited language tag for the given request" @@ -75,7 +73,7 @@ RESTfulControllerAcceptNegotiator >> bestLanguageFor: anHttpRequest [ inAnyOf: availableLanguageTags ] -{ #category : 'querying' } +{ #category : #querying } RESTfulControllerAcceptNegotiator >> bestRepresentationFor: anHttpRequest [ "This method returns the best suited representation for the given request" @@ -84,14 +82,14 @@ RESTfulControllerAcceptNegotiator >> bestRepresentationFor: anHttpRequest [ HTTPNotAcceptable signal: 'Cannot generate a response entity with acceptable characteristics.' accepting: availableMediaTypes ] -{ #category : 'initialize - release' } +{ #category : #'initialize - release' } RESTfulControllerAcceptNegotiator >> initializeAccepting: aMediaTypeCollection inAnyOf: aLanguageTagCollection [ availableMediaTypes := aMediaTypeCollection. availableLanguageTags := aLanguageTagCollection ] -{ #category : 'private - accessing' } +{ #category : #'private - accessing' } RESTfulControllerAcceptNegotiator >> mediaTypesAvailableFor: aMediaType [ ^ availableMediaTypes @@ -100,7 +98,7 @@ RESTfulControllerAcceptNegotiator >> mediaTypesAvailableFor: aMediaType [ and: [ self versionIn: aMediaType canBeHandledBy: available ] ] ] -{ #category : 'private - accessing' } +{ #category : #'private - accessing' } RESTfulControllerAcceptNegotiator >> precedenceFor: aMediaType [ | precedence version versionParts | @@ -121,19 +119,19 @@ RESTfulControllerAcceptNegotiator >> precedenceFor: aMediaType [ ^ precedence ] -{ #category : 'private - accessing' } +{ #category : #'private - accessing' } RESTfulControllerAcceptNegotiator >> sortByPrecedence: mediaTypes [ ^ mediaTypes sorted: [ :mediaType | self precedenceFor: mediaType ] descending ] -{ #category : 'private - accessing' } +{ #category : #'private - accessing' } RESTfulControllerAcceptNegotiator >> splitMediaTypesIn: acceptList [ ^ ( ',' split: acceptList ) collect: [ :type | type asMediaType ] ] -{ #category : 'private - accessing' } +{ #category : #'private - accessing' } RESTfulControllerAcceptNegotiator >> splitQualifiedLanguageRangesIn: acceptLanguageList [ ^ ( ',' split: acceptLanguageList ) @@ -148,7 +146,7 @@ RESTfulControllerAcceptNegotiator >> splitQualifiedLanguageRangesIn: acceptLangu ] ] -{ #category : 'private - accessing' } +{ #category : #'private - accessing' } RESTfulControllerAcceptNegotiator >> versionIn: acceptable canBeHandledBy: available [ | acceptVersion availableVersion acceptVersionParts availableVersionParts | @@ -166,7 +164,7 @@ RESTfulControllerAcceptNegotiator >> versionIn: acceptable canBeHandledBy: avail ^ true ] -{ #category : 'private - accessing' } +{ #category : #'private - accessing' } RESTfulControllerAcceptNegotiator >> withAcceptableLanguageRangesIn: anHttpRequest do: aBlock [ | acceptable grouped | @@ -180,7 +178,7 @@ RESTfulControllerAcceptNegotiator >> withAcceptableLanguageRangesIn: anHttpReque do: [ :quality | ( grouped at: quality ) do: [ :qualifiedRange | aBlock value: qualifiedRange range ] ] ] -{ #category : 'private - accessing' } +{ #category : #'private - accessing' } RESTfulControllerAcceptNegotiator >> withAcceptableMediaTypesIn: anHttpRequest do: aBlock [ | acceptable grouped | diff --git a/source/Stargate-Model/RESTfulControllerDoNotPaginateCollectionsPolicy.class.st b/source/Stargate-Model/RESTfulControllerDoNotPaginateCollectionsPolicy.class.st index ff8cbbb..24c2440 100644 --- a/source/Stargate-Model/RESTfulControllerDoNotPaginateCollectionsPolicy.class.st +++ b/source/Stargate-Model/RESTfulControllerDoNotPaginateCollectionsPolicy.class.st @@ -2,39 +2,37 @@ I'm the policy indicating a RESTful controller to not support pagination of collections related to the controlled resource. " Class { - #name : 'RESTfulControllerDoNotPaginateCollectionsPolicy', - #superclass : 'RESTfulControllerPaginationPolicy', + #name : #RESTfulControllerDoNotPaginateCollectionsPolicy, + #superclass : #RESTfulControllerPaginationPolicy, #instVars : [ 'requestHandler' ], - #category : 'Stargate-Model-Pagination', - #package : 'Stargate-Model', - #tag : 'Pagination' + #category : 'Stargate-Model-Pagination' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } RESTfulControllerDoNotPaginateCollectionsPolicy class >> for: aRequestHandler [ ^ self new initializeFor: aRequestHandler ] -{ #category : 'applying' } +{ #category : #applying } RESTfulControllerDoNotPaginateCollectionsPolicy >> addPaginationControlsTo: mediaControls within: requestContext [ ^ mediaControls ] -{ #category : 'applying' } +{ #category : #applying } RESTfulControllerDoNotPaginateCollectionsPolicy >> affect: response within: requestContext [ ] -{ #category : 'applying' } +{ #category : #applying } RESTfulControllerDoNotPaginateCollectionsPolicy >> evaluateQuery: aQueryEvaluationBlock basedOn: httpRequest [ ^ requestHandler evaluateCollectionQuery: aQueryEvaluationBlock ] -{ #category : 'initialization' } +{ #category : #initialization } RESTfulControllerDoNotPaginateCollectionsPolicy >> initializeFor: aRequestHandler [ requestHandler := aRequestHandler diff --git a/source/Stargate-Model/RESTfulControllerDoNotRespondCreatedEntityPolicy.class.st b/source/Stargate-Model/RESTfulControllerDoNotRespondCreatedEntityPolicy.class.st index 87f3bcc..41c56ed 100644 --- a/source/Stargate-Model/RESTfulControllerDoNotRespondCreatedEntityPolicy.class.st +++ b/source/Stargate-Model/RESTfulControllerDoNotRespondCreatedEntityPolicy.class.st @@ -2,29 +2,27 @@ I'm a policy configuring a controller in such a way that responses for creation requests will not respond immediately with a representation of the created resource. " Class { - #name : 'RESTfulControllerDoNotRespondCreatedEntityPolicy', - #superclass : 'RESTfulControllerResourceCreationPolicy', + #name : #RESTfulControllerDoNotRespondCreatedEntityPolicy, + #superclass : #RESTfulControllerResourceCreationPolicy, #instVars : [ 'requestHandler' ], - #category : 'Stargate-Model-Controllers', - #package : 'Stargate-Model', - #tag : 'Controllers' + #category : 'Stargate-Model-Controllers' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } RESTfulControllerDoNotRespondCreatedEntityPolicy class >> for: aRequestHandler [ ^ self new initializeFor: aRequestHandler ] -{ #category : 'initialization' } +{ #category : #initialization } RESTfulControllerDoNotRespondCreatedEntityPolicy >> initializeFor: aRequestHandler [ requestHandler := aRequestHandler ] -{ #category : 'processing' } +{ #category : #processing } RESTfulControllerDoNotRespondCreatedEntityPolicy >> responseFor: resource basedOn: httpRequest within: requestContext [ ^ ZnResponse created: ( requestHandler locationOf: resource within: requestContext ) diff --git a/source/Stargate-Model/RESTfulControllerPaginateCollectionsPolicy.class.st b/source/Stargate-Model/RESTfulControllerPaginateCollectionsPolicy.class.st index c134779..ff13dc8 100644 --- a/source/Stargate-Model/RESTfulControllerPaginateCollectionsPolicy.class.st +++ b/source/Stargate-Model/RESTfulControllerPaginateCollectionsPolicy.class.st @@ -2,36 +2,34 @@ I'm the policy indicating a RESTful controller to support pagination of collections related to the controlled resource. " Class { - #name : 'RESTfulControllerPaginateCollectionsPolicy', - #superclass : 'RESTfulControllerPaginationPolicy', + #name : #RESTfulControllerPaginateCollectionsPolicy, + #superclass : #RESTfulControllerPaginationPolicy, #instVars : [ 'defaultLimit', 'requestHandler' ], - #category : 'Stargate-Model-Pagination', - #package : 'Stargate-Model', - #tag : 'Pagination' + #category : 'Stargate-Model-Pagination' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } RESTfulControllerPaginateCollectionsPolicy class >> for: aRequestHandler with: aPaginationLimit [ ^ self new initializeFor: aRequestHandler with: aPaginationLimit ] -{ #category : 'applying' } +{ #category : #applying } RESTfulControllerPaginateCollectionsPolicy >> addPaginationControlsTo: mediaControls within: requestContext [ ^ mediaControls , requestContext paginationControls ] -{ #category : 'applying' } +{ #category : #applying } RESTfulControllerPaginateCollectionsPolicy >> affect: response within: requestContext [ requestContext paginationControls do: [ :link | response addLink: link ] ] -{ #category : 'applying' } +{ #category : #applying } RESTfulControllerPaginateCollectionsPolicy >> evaluateQuery: aQueryEvaluationBlock basedOn: httpRequest [ | pagination | @@ -42,14 +40,14 @@ RESTfulControllerPaginateCollectionsPolicy >> evaluateQuery: aQueryEvaluationBlo ^ requestHandler evaluateCollectionQuery: [ aQueryEvaluationBlock cull: pagination ] ] -{ #category : 'initialization' } +{ #category : #initialization } RESTfulControllerPaginateCollectionsPolicy >> initializeFor: aRequestHandler with: aPaginationLimit [ requestHandler := aRequestHandler. defaultLimit := aPaginationLimit ] -{ #category : 'private' } +{ #category : #private } RESTfulControllerPaginateCollectionsPolicy >> paginationFrom: httpRequest [ ^ PaginationSpecification diff --git a/source/Stargate-Model/RESTfulControllerPaginationPolicy.class.st b/source/Stargate-Model/RESTfulControllerPaginationPolicy.class.st index c458f1f..bf3a490 100644 --- a/source/Stargate-Model/RESTfulControllerPaginationPolicy.class.st +++ b/source/Stargate-Model/RESTfulControllerPaginationPolicy.class.st @@ -2,26 +2,24 @@ I'm the policy used to control pagination in a RESTfulController " Class { - #name : 'RESTfulControllerPaginationPolicy', - #superclass : 'Object', - #category : 'Stargate-Model-Pagination', - #package : 'Stargate-Model', - #tag : 'Pagination' + #name : #RESTfulControllerPaginationPolicy, + #superclass : #Object, + #category : 'Stargate-Model-Pagination' } -{ #category : 'applying' } +{ #category : #applying } RESTfulControllerPaginationPolicy >> addPaginationControlsTo: mediaControls within: httpRequest [ ^ self subclassResponsibility ] -{ #category : 'applying' } +{ #category : #applying } RESTfulControllerPaginationPolicy >> affect: response within: requestContext [ self subclassResponsibility ] -{ #category : 'applying' } +{ #category : #applying } RESTfulControllerPaginationPolicy >> evaluateQuery: aQueryEvaluationBlock basedOn: httpRequest [ self subclassResponsibility diff --git a/source/Stargate-Model/RESTfulControllerResourceCreationPolicy.class.st b/source/Stargate-Model/RESTfulControllerResourceCreationPolicy.class.st index 1a9c095..fcc8b01 100644 --- a/source/Stargate-Model/RESTfulControllerResourceCreationPolicy.class.st +++ b/source/Stargate-Model/RESTfulControllerResourceCreationPolicy.class.st @@ -2,14 +2,12 @@ I'm an abstract policy controlling how to respond on the creation of new resources. " Class { - #name : 'RESTfulControllerResourceCreationPolicy', - #superclass : 'Object', - #category : 'Stargate-Model-Controllers', - #package : 'Stargate-Model', - #tag : 'Controllers' + #name : #RESTfulControllerResourceCreationPolicy, + #superclass : #Object, + #category : 'Stargate-Model-Controllers' } -{ #category : 'processing' } +{ #category : #processing } RESTfulControllerResourceCreationPolicy >> responseFor: resource basedOn: httpRequest within: requestContext [ self subclassResponsibility diff --git a/source/Stargate-Model/RESTfulControllerRespondCreatedEntityPolicy.class.st b/source/Stargate-Model/RESTfulControllerRespondCreatedEntityPolicy.class.st index d8029e6..2ad5b75 100644 --- a/source/Stargate-Model/RESTfulControllerRespondCreatedEntityPolicy.class.st +++ b/source/Stargate-Model/RESTfulControllerRespondCreatedEntityPolicy.class.st @@ -2,29 +2,27 @@ I'm a policy configuring a controller in such a way that responses for creation requests will respond immediately with a representation of the created resource. " Class { - #name : 'RESTfulControllerRespondCreatedEntityPolicy', - #superclass : 'RESTfulControllerResourceCreationPolicy', + #name : #RESTfulControllerRespondCreatedEntityPolicy, + #superclass : #RESTfulControllerResourceCreationPolicy, #instVars : [ 'requestHandler' ], - #category : 'Stargate-Model-Controllers', - #package : 'Stargate-Model', - #tag : 'Controllers' + #category : 'Stargate-Model-Controllers' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } RESTfulControllerRespondCreatedEntityPolicy class >> for: aRequestHandler [ ^ self new initializeFor: aRequestHandler ] -{ #category : 'initialization' } +{ #category : #initialization } RESTfulControllerRespondCreatedEntityPolicy >> initializeFor: aRequestHandler [ requestHandler := aRequestHandler ] -{ #category : 'processing' } +{ #category : #processing } RESTfulControllerRespondCreatedEntityPolicy >> responseFor: resource basedOn: httpRequest within: requestContext [ | response | diff --git a/source/Stargate-Model/RESTfulRequestExceptionHandler.class.st b/source/Stargate-Model/RESTfulRequestExceptionHandler.class.st index 136bbe2..de14acc 100644 --- a/source/Stargate-Model/RESTfulRequestExceptionHandler.class.st +++ b/source/Stargate-Model/RESTfulRequestExceptionHandler.class.st @@ -2,23 +2,21 @@ I'm an exception handler to be used while handling a RESTful HTTP request " Class { - #name : 'RESTfulRequestExceptionHandler', - #superclass : 'Object', + #name : #RESTfulRequestExceptionHandler, + #superclass : #Object, #instVars : [ 'exceptionsToHandle' ], - #category : 'Stargate-Model-Controllers', - #package : 'Stargate-Model', - #tag : 'Controllers' + #category : 'Stargate-Model-Controllers' } -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestExceptionHandler >> addAsConflictError: anExceptionSelector [ exceptionsToHandle at: #conflict put: ( exceptionsToHandle at: #conflict ) , anExceptionSelector ] -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestExceptionHandler >> addAsDecodingError: anExceptionSelector [ exceptionsToHandle @@ -26,7 +24,7 @@ RESTfulRequestExceptionHandler >> addAsDecodingError: anExceptionSelector [ put: ( exceptionsToHandle at: #decodingFailed ) , anExceptionSelector ] -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestExceptionHandler >> addAsMissingQueryParameterError: anExceptionSelector [ exceptionsToHandle @@ -34,19 +32,19 @@ RESTfulRequestExceptionHandler >> addAsMissingQueryParameterError: anExceptionSe put: ( exceptionsToHandle at: #missingQueryParameters ) , anExceptionSelector ] -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestExceptionHandler >> addAsNotFoundError: anExceptionSelector [ exceptionsToHandle at: #notFound put: ( exceptionsToHandle at: #notFound ) , anExceptionSelector ] -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestExceptionHandler >> addAsUnprocessableEntityError: anExceptionSelector [ exceptionsToHandle at: #unprocessableEntity put: ( exceptionsToHandle at: #unprocessableEntity ) , anExceptionSelector ] -{ #category : 'handling' } +{ #category : #handling } RESTfulRequestExceptionHandler >> handleConflictsDuring: aBlock [ ^ aBlock @@ -54,7 +52,7 @@ RESTfulRequestExceptionHandler >> handleConflictsDuring: aBlock [ do: [ :signal | HTTPClientError conflict signal: signal messageText ] ] -{ #category : 'handling' } +{ #category : #handling } RESTfulRequestExceptionHandler >> handleDecodingFailedDuring: aBlock [ ^ [ @@ -66,7 +64,7 @@ RESTfulRequestExceptionHandler >> handleDecodingFailedDuring: aBlock [ do: [ :signal | HTTPClientError unprocessableEntity signal: signal messageText ] ] -{ #category : 'handling' } +{ #category : #handling } RESTfulRequestExceptionHandler >> handleMissingQueryParametersDuring: aBlock [ ^ aBlock @@ -74,13 +72,13 @@ RESTfulRequestExceptionHandler >> handleMissingQueryParametersDuring: aBlock [ do: [ :signal | HTTPClientError badRequest signal: signal messageText ] ] -{ #category : 'handling' } +{ #category : #handling } RESTfulRequestExceptionHandler >> handleNotFoundAndMissingParametersDuring: aBlock [ ^ self handleNotFoundDuring: [ self handleMissingQueryParametersDuring: aBlock ] ] -{ #category : 'handling' } +{ #category : #handling } RESTfulRequestExceptionHandler >> handleNotFoundDuring: aBlock [ ^ aBlock @@ -88,7 +86,7 @@ RESTfulRequestExceptionHandler >> handleNotFoundDuring: aBlock [ do: [ :signal | HTTPClientError notFound signal: signal messageText ] ] -{ #category : 'initialization' } +{ #category : #initialization } RESTfulRequestExceptionHandler >> initialize [ super initialize. diff --git a/source/Stargate-Model/RESTfulRequestHandler.class.st b/source/Stargate-Model/RESTfulRequestHandler.class.st index 84d71af..446e03e 100644 --- a/source/Stargate-Model/RESTfulRequestHandler.class.st +++ b/source/Stargate-Model/RESTfulRequestHandler.class.st @@ -3,26 +3,24 @@ I represent a RESTful handler, and provide the base support to easily create spe I provide the standard machinery to handle REST requests, and I'm supposed to be used from a controller. " Class { - #name : 'RESTfulRequestHandler', - #superclass : 'RESTfulRequestHandlerBehavior', - #category : 'Stargate-Model-Controllers', - #package : 'Stargate-Model', - #tag : 'Controllers' + #name : #RESTfulRequestHandler, + #superclass : #RESTfulRequestHandlerBehavior, + #category : 'Stargate-Model-Controllers' } -{ #category : 'encoding' } +{ #category : #encoding } RESTfulRequestHandler class >> encode: resource toJsonUsing: writer as: schema within: requestContext [ writer nextPut: resource as: schema ] -{ #category : 'encoding' } +{ #category : #encoding } RESTfulRequestHandler class >> encode: resource toJsonUsing: writer within: requestContext [ writer nextPut: resource ] -{ #category : 'instance creation' } +{ #category : #'instance creation' } RESTfulRequestHandler class >> resourceLocator: aResouceLocator paginationPolicy: aPaginationPolicy decodingRules: theDecodingRules encodingRules: theEncodingRules calculateEntityTagsWith: entityTagCalculator cachingDirectives: theCachingDirectives allowedLanguageTags: allowedLanguageTags handleErrorsWith: anExceptionHandler [ ^ self new diff --git a/source/Stargate-Model/RESTfulRequestHandlerBehavior.class.st b/source/Stargate-Model/RESTfulRequestHandlerBehavior.class.st index 93bf63f..a9b6b25 100644 --- a/source/Stargate-Model/RESTfulRequestHandlerBehavior.class.st +++ b/source/Stargate-Model/RESTfulRequestHandlerBehavior.class.st @@ -3,8 +3,8 @@ I represent a RESTful handler, and provide the base support to easily create spe I provide the standard machinery to handle REST requests, and I'm supposed to be used from a controller. " Class { - #name : 'RESTfulRequestHandlerBehavior', - #superclass : 'Object', + #name : #RESTfulRequestHandlerBehavior, + #superclass : #Object, #instVars : [ 'paginationPolicy', 'decodingRules', @@ -14,38 +14,36 @@ Class { 'acceptNegotiator', 'cachingDirectives' ], - #category : 'Stargate-Model-Controllers', - #package : 'Stargate-Model', - #tag : 'Controllers' + #category : 'Stargate-Model-Controllers' } -{ #category : 'encoding' } +{ #category : #encoding } RESTfulRequestHandlerBehavior class >> encode: resource toJsonUsing: writer as: schema within: requestContext [ self subclassResponsibility ] -{ #category : 'encoding' } +{ #category : #encoding } RESTfulRequestHandlerBehavior class >> encode: resource toJsonUsing: writer within: requestContext [ self subclassResponsibility ] -{ #category : 'private' } +{ #category : #private } RESTfulRequestHandlerBehavior >> applyCachingDirectivesFor: aResource to: response within: requestContext [ cachingDirectives do: [ :directive | directive cull: response cull: requestContext cull: aResource ] ] -{ #category : 'private' } +{ #category : #private } RESTfulRequestHandlerBehavior >> assert: etag matchesEntityTagOf: entity encodedAs: mediaType within: requestContext [ etag = ( self entityTagOf: entity encodedAs: mediaType within: requestContext ) ifFalse: [ HTTPClientError preconditionFailed signal ] ] -{ #category : 'decoding/encoding' } +{ #category : #'decoding/encoding' } RESTfulRequestHandlerBehavior >> decode: httpRequest within: requestContext [ | decodingRule | @@ -58,7 +56,7 @@ RESTfulRequestHandlerBehavior >> decode: httpRequest within: requestContext [ handleDecodingFailedDuring: [ decodingRule cull: httpRequest contents cull: requestContext ] ] -{ #category : 'decoding/encoding' } +{ #category : #'decoding/encoding' } RESTfulRequestHandlerBehavior >> encode: resource as: targetMediaType within: requestContext [ | encodingRule | @@ -69,7 +67,7 @@ RESTfulRequestHandlerBehavior >> encode: resource as: targetMediaType within: re ^ encodingRule encode: resource within: requestContext ] -{ #category : 'decoding/encoding' } +{ #category : #'decoding/encoding' } RESTfulRequestHandlerBehavior >> encode: resource within: requestContext [ ^ self @@ -78,13 +76,13 @@ RESTfulRequestHandlerBehavior >> encode: resource within: requestContext [ within: requestContext ] -{ #category : 'private' } +{ #category : #private } RESTfulRequestHandlerBehavior >> encodeResource: resource as: mediaType within: requestContext [ ^ self encode: resource as: mediaType within: requestContext ] -{ #category : 'private' } +{ #category : #private } RESTfulRequestHandlerBehavior >> encodeResource: resource within: requestContext [ ^ self @@ -93,19 +91,19 @@ RESTfulRequestHandlerBehavior >> encodeResource: resource within: requestContext within: requestContext ] -{ #category : 'private' } +{ #category : #private } RESTfulRequestHandlerBehavior >> encodeResourceCollection: resourceCollection basedOn: httpRequest within: requestContext [ ^ self encode: resourceCollection within: requestContext ] -{ #category : 'accessing' } +{ #category : #accessing } RESTfulRequestHandlerBehavior >> endpoint [ ^ resourceLocator endpoint ] -{ #category : 'private' } +{ #category : #private } RESTfulRequestHandlerBehavior >> entityTagOf: resource encodedAs: mediaType within: requestContext [ ^ EntityTag with: (entityTagCalculator @@ -115,7 +113,7 @@ RESTfulRequestHandlerBehavior >> entityTagOf: resource encodedAs: mediaType with value: self) ] -{ #category : 'private' } +{ #category : #private } RESTfulRequestHandlerBehavior >> entityTagToMatchBasedOn: httpRequest [ ^ (httpRequest headers at: 'If-Match' ifAbsent: [ @@ -123,19 +121,19 @@ RESTfulRequestHandlerBehavior >> entityTagToMatchBasedOn: httpRequest [ 'Missing If-Match header.' ]) asEntityTag ] -{ #category : 'private' } +{ #category : #private } RESTfulRequestHandlerBehavior >> evaluateCollectionQuery: aQueryEvaluationBlock [ ^ self exceptionHandler handleMissingQueryParametersDuring: aQueryEvaluationBlock ] -{ #category : 'accessing' } +{ #category : #accessing } RESTfulRequestHandlerBehavior >> exceptionHandler [ ^ resourceLocator exceptionHandler ] -{ #category : 'API' } +{ #category : #API } RESTfulRequestHandlerBehavior >> from: httpRequest within: requestContext get: aQueryEvaluationBlock [ | resource response | @@ -167,7 +165,7 @@ RESTfulRequestHandlerBehavior >> from: httpRequest within: requestContext get: a ^ response ] -{ #category : 'API' } +{ #category : #API } RESTfulRequestHandlerBehavior >> from: httpRequest within: requestContext get: aQueryEvaluationBlock thenDo: actionBlock [ | resource | @@ -179,7 +177,7 @@ RESTfulRequestHandlerBehavior >> from: httpRequest within: requestContext get: a ^ ZnResponse noContent ] -{ #category : 'API' } +{ #category : #API } RESTfulRequestHandlerBehavior >> from: httpRequest within: requestContext get: findBlock thenUpdateWith: updateBlock [ | etag | @@ -207,7 +205,7 @@ RESTfulRequestHandlerBehavior >> from: httpRequest within: requestContext get: f ] ] -{ #category : 'API' } +{ #category : #API } RESTfulRequestHandlerBehavior >> from: httpRequest within: requestContext getCollection: aQueryEvaluationBlock [ | resourceCollection encodedResourceCollection response | @@ -227,7 +225,7 @@ RESTfulRequestHandlerBehavior >> from: httpRequest within: requestContext getCol ^ response ] -{ #category : 'private' } +{ #category : #private } RESTfulRequestHandlerBehavior >> holdTargetMediaTypeAndLanguageFrom: httpRequest within: requestContext [ httpRequest hasLanguageProrityList @@ -236,7 +234,7 @@ RESTfulRequestHandlerBehavior >> holdTargetMediaTypeAndLanguageFrom: httpRequest ^ requestContext targetMediaType: ( acceptNegotiator bestRepresentationFor: httpRequest ) ] -{ #category : 'private' } +{ #category : #private } RESTfulRequestHandlerBehavior >> ifNoneMatchHeaderPresentIn: httpRequest do: aMonadycBlock [ httpRequest headers @@ -245,7 +243,7 @@ RESTfulRequestHandlerBehavior >> ifNoneMatchHeaderPresentIn: httpRequest do: aMo aMonadycBlock value: ifNoneMatchHeader asEntityTag ] ] -{ #category : 'initialization' } +{ #category : #initialization } RESTfulRequestHandlerBehavior >> initializeResourceLocator: aResouceLocator paginationPolicy: aPaginationPolicy decodingRules: theDecodingRules @@ -265,19 +263,19 @@ RESTfulRequestHandlerBehavior >> initializeResourceLocator: aResouceLocator cachingDirectives := theCachingDirectives ] -{ #category : 'private' } +{ #category : #private } RESTfulRequestHandlerBehavior >> locationOf: resource within: requestContext [ ^ resourceLocator locationOf: resource within: requestContext ] -{ #category : 'private' } +{ #category : #private } RESTfulRequestHandlerBehavior >> paginationPolicy [ ^ paginationPolicy ] -{ #category : 'private' } +{ #category : #private } RESTfulRequestHandlerBehavior >> putEntityTagOf: resource in: response within: requestContext [ response @@ -285,7 +283,7 @@ RESTfulRequestHandlerBehavior >> putEntityTagOf: resource in: response within: r addToVary: 'Accept' ] -{ #category : 'private' } +{ #category : #private } RESTfulRequestHandlerBehavior >> putLanguageContentTagIn: response within: requestContext [ requestContext @@ -296,7 +294,7 @@ RESTfulRequestHandlerBehavior >> putLanguageContentTagIn: response within: reque ] ] -{ #category : 'private' } +{ #category : #private } RESTfulRequestHandlerBehavior >> resourceCreationPolicyBasedOn: httpRequest within: requestContext [ ^ httpRequest @@ -307,19 +305,19 @@ RESTfulRequestHandlerBehavior >> resourceCreationPolicyBasedOn: httpRequest with ifAbsent: [ RESTfulControllerDoNotRespondCreatedEntityPolicy for: self ] ] -{ #category : 'accessing' } +{ #category : #accessing } RESTfulRequestHandlerBehavior >> resourceLocator [ ^ resourceLocator ] -{ #category : 'accessing' } +{ #category : #accessing } RESTfulRequestHandlerBehavior >> serverUrl: aServerUrl [ resourceLocator baseUrl: aServerUrl ] -{ #category : 'API' } +{ #category : #API } RESTfulRequestHandlerBehavior >> withRepresentationIn: httpRequest within: requestContext createResourceWith: aCreationBlock thenDo: aBlock [ ^ self @@ -331,7 +329,7 @@ RESTfulRequestHandlerBehavior >> withRepresentationIn: httpRequest within: reque ] ] -{ #category : 'API' } +{ #category : #API } RESTfulRequestHandlerBehavior >> withResourceCreatedFrom: httpRequest within: requestContext do: aBlock [ | creationPolicy decodedRepresentation newResource | diff --git a/source/Stargate-Model/RESTfulRequestHandlerBuilder.class.st b/source/Stargate-Model/RESTfulRequestHandlerBuilder.class.st index 23222e5..bf6225e 100644 --- a/source/Stargate-Model/RESTfulRequestHandlerBuilder.class.st +++ b/source/Stargate-Model/RESTfulRequestHandlerBuilder.class.st @@ -2,8 +2,8 @@ I'm a builder of RESTful handlers " Class { - #name : 'RESTfulRequestHandlerBuilder', - #superclass : 'Object', + #name : #RESTfulRequestHandlerBuilder, + #superclass : #Object, #instVars : [ 'decodingRules', 'encodingRules', @@ -16,24 +16,22 @@ Class { 'requestHandlerClass', 'requestHandlerFactory' ], - #category : 'Stargate-Model-Controllers', - #package : 'Stargate-Model', - #tag : 'Controllers' + #category : 'Stargate-Model-Controllers' } -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestHandlerBuilder >> addAsSupportedLanguage: aLanguageTag [ allowedLanguageTags add: aLanguageTag asLanguageTag ] -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestHandlerBuilder >> beHypermediaDriven [ self beHypermediaDrivenBy: [ ] ] -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestHandlerBuilder >> beHypermediaDrivenBy: aMediaControlsFactoryBlock [ AssertionChecker @@ -63,13 +61,13 @@ RESTfulRequestHandlerBuilder >> beHypermediaDrivenBy: aMediaControlsFactoryBlock ] ] -{ #category : 'building' } +{ #category : #building } RESTfulRequestHandlerBuilder >> build [ ^ requestHandlerFactory value ] -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestHandlerBuilder >> createEntityTagHashing: aBlockClosure [ self @@ -83,7 +81,7 @@ RESTfulRequestHandlerBuilder >> createEntityTagHashing: aBlockClosure [ ] ] -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestHandlerBuilder >> createEntityTagHashingEncodedResource [ self @@ -94,19 +92,19 @@ RESTfulRequestHandlerBuilder >> createEntityTagHashingEncodedResource [ ] ] -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestHandlerBuilder >> createEntityTagWith: aBlock [ entityTagFactoryBinding := Binding to: aBlock ] -{ #category : 'decoding' } +{ #category : #decoding } RESTfulRequestHandlerBuilder >> decodeToNeoJSONObjectWhenAccepting: aMediaType [ self whenAccepting: aMediaType decodeApplying: [ :json | NeoJSONObject fromString: json ] ] -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestHandlerBuilder >> directCachingWith: aBlock [ cachingDirectives := CachingDirectivesBuilder new @@ -114,25 +112,25 @@ RESTfulRequestHandlerBuilder >> directCachingWith: aBlock [ build ] -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestHandlerBuilder >> handleExceptionsApplying: aBlock [ aBlock value: exceptionHandler ] -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestHandlerBuilder >> handling: anEndpoint [ resourceLocator := ResourceLocator handling: anEndpoint ] -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestHandlerBuilder >> handling: anEndpoint extractingIdentifierWith: aBlock [ resourceLocator := ResourceLocator handling: anEndpoint extractingIdentifierWith: aBlock ] -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestHandlerBuilder >> handling: anEndpoint extractingIdentifierWith: aBlock locatingParentResourceWith: aResourceLocator [ resourceLocator := SubresourceLocator @@ -141,7 +139,7 @@ RESTfulRequestHandlerBuilder >> handling: anEndpoint extractingIdentifierWith: a locatingParentResourceWith: aResourceLocator ] -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestHandlerBuilder >> handling: anEndpoint locatingResourcesWith: aLocationBlock extractingIdentifierWith: aBlock [ resourceLocator := ResourceLocator @@ -150,7 +148,7 @@ RESTfulRequestHandlerBuilder >> handling: anEndpoint locatingResourcesWith: aLoc andIdentifierBy: aBlock ] -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestHandlerBuilder >> handling: anEndpoint locatingSubresourcesWith: aLocationBlock extractingIdentifierWith: aBlock locatingParentResourceWith: aResourceLocator [ resourceLocator := SubresourceLocator @@ -160,7 +158,7 @@ RESTfulRequestHandlerBuilder >> handling: anEndpoint locatingSubresourcesWith: a locatingParentResourceWith: aResourceLocator ] -{ #category : 'initialization' } +{ #category : #initialization } RESTfulRequestHandlerBuilder >> initialize [ super initialize. @@ -186,7 +184,7 @@ RESTfulRequestHandlerBuilder >> initialize [ ] ] -{ #category : 'private' } +{ #category : #private } RESTfulRequestHandlerBuilder >> jsonFor: resource within: requestContext applying: aBlock writingResourceWith: aResourceWritingBlock [ ^ String streamContents: [ :stream | @@ -197,13 +195,13 @@ RESTfulRequestHandlerBuilder >> jsonFor: resource within: requestContext applyin ] ] -{ #category : 'configuring' } +{ #category : #configuring } RESTfulRequestHandlerBuilder >> paginateCollectionsWithDefaultLimit: anInteger [ paginationPolicyFactory := [ :processor | RESTfulControllerPaginateCollectionsPolicy for: processor with: anInteger ] ] -{ #category : 'decoding' } +{ #category : #decoding } RESTfulRequestHandlerBuilder >> whenAccepting: aMediaType decodeApplying: aDecodingBlock [ "aDecodingBlock will be evaluated with the request contents and optionally the request context" @@ -214,7 +212,7 @@ RESTfulRequestHandlerBuilder >> whenAccepting: aMediaType decodeApplying: aDecod ifAbsentPut: [ aDecodingBlock ] ] -{ #category : 'decoding' } +{ #category : #decoding } RESTfulRequestHandlerBuilder >> whenAccepting: aMediaType decodeFromJsonApplying: aBlock [ self @@ -222,7 +220,7 @@ RESTfulRequestHandlerBuilder >> whenAccepting: aMediaType decodeFromJsonApplying decodeApplying: [ :json | aBlock value: json value: ( NeoJSONReader on: json readStream ) ] ] -{ #category : 'encoding' } +{ #category : #encoding } RESTfulRequestHandlerBuilder >> whenResponding: aMediaType encodeApplying: anEncodingBlock [ encodingRules @@ -231,7 +229,7 @@ RESTfulRequestHandlerBuilder >> whenResponding: aMediaType encodeApplying: anEnc ifAbsentPut: [ ResourceEncodingRule encoding: aMediaType using: anEncodingBlock ] ] -{ #category : 'encoding' } +{ #category : #encoding } RESTfulRequestHandlerBuilder >> whenResponding: aMediaType encodeToJsonApplying: aBlock [ self whenResponding: aMediaType encodeApplying: [ :resource :requestContext | @@ -244,7 +242,7 @@ RESTfulRequestHandlerBuilder >> whenResponding: aMediaType encodeToJsonApplying: ] ] -{ #category : 'encoding' } +{ #category : #encoding } RESTfulRequestHandlerBuilder >> whenResponding: aMediaType encodeToJsonApplying: aBlock as: schema [ self whenResponding: aMediaType encodeApplying: [ :resource :requestContext | diff --git a/source/Stargate-Model/ReflectiveRoutesConfigurator.class.st b/source/Stargate-Model/ReflectiveRoutesConfigurator.class.st index 721015a..2dbdc3c 100644 --- a/source/Stargate-Model/ReflectiveRoutesConfigurator.class.st +++ b/source/Stargate-Model/ReflectiveRoutesConfigurator.class.st @@ -4,29 +4,27 @@ I'm a reflective configurator of web service routes. I'm being used to configure a Teapot server routes reflectively. I expect web service specification declare its routes on messages that follow the pattern #*Route " Class { - #name : 'ReflectiveRoutesConfigurator', - #superclass : 'Object', + #name : #ReflectiveRoutesConfigurator, + #superclass : #Object, #instVars : [ 'teapot' ], - #category : 'Stargate-Model-Routing', - #package : 'Stargate-Model', - #tag : 'Routing' + #category : 'Stargate-Model-Routing' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } ReflectiveRoutesConfigurator class >> appliedTo: aTeapot [ ^ self new initializeAppliedTo: aTeapot ] -{ #category : 'configuring' } +{ #category : #configuring } ReflectiveRoutesConfigurator >> addRoutesOf: aResourceRESTfulController [ (RouteConfigurator configuring: teapot withRoutesDefinedOn: aResourceRESTfulController) configure ] -{ #category : 'initialization' } +{ #category : #initialization } ReflectiveRoutesConfigurator >> initializeAppliedTo: aTeapot [ teapot := aTeapot diff --git a/source/Stargate-Model/ResourceCollection.class.st b/source/Stargate-Model/ResourceCollection.class.st index 4d7ec03..61a58e9 100644 --- a/source/Stargate-Model/ResourceCollection.class.st +++ b/source/Stargate-Model/ResourceCollection.class.st @@ -5,29 +5,27 @@ I'm used internally in Hypermedia driven controllers to ease the media control c I'm not intended to be used externally. " Class { - #name : 'ResourceCollection', - #superclass : 'Object', + #name : #ResourceCollection, + #superclass : #Object, #instVars : [ 'items' ], - #category : 'Stargate-Model-HATEOAS', - #package : 'Stargate-Model', - #tag : 'HATEOAS' + #category : 'Stargate-Model-HATEOAS' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } ResourceCollection class >> wrapping: aCollection [ ^self new initializeWrapping: aCollection ] -{ #category : 'initialization' } +{ #category : #initialization } ResourceCollection >> initializeWrapping: aCollection [ items := aCollection ] -{ #category : 'accessing' } +{ #category : #accessing } ResourceCollection >> items [ ^ items diff --git a/source/Stargate-Model/ResourceEncodingRule.class.st b/source/Stargate-Model/ResourceEncodingRule.class.st index 7842079..750b409 100644 --- a/source/Stargate-Model/ResourceEncodingRule.class.st +++ b/source/Stargate-Model/ResourceEncodingRule.class.st @@ -3,30 +3,28 @@ I'm an encoding rule. I'm responsible of generating an Entity with the provided media type encoding a resource into it's representation. " Class { - #name : 'ResourceEncodingRule', - #superclass : 'Object', + #name : #ResourceEncodingRule, + #superclass : #Object, #instVars : [ 'mediaType', 'encodingBlock' ], - #category : 'Stargate-Model-Controllers', - #package : 'Stargate-Model', - #tag : 'Controllers' + #category : 'Stargate-Model-Controllers' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } ResourceEncodingRule class >> encoding: aMediaType using: aWriter [ ^ self new initializeMapping: aMediaType using: aWriter ] -{ #category : 'encoding' } +{ #category : #encoding } ResourceEncodingRule >> encode: resource within: requestContext [ ^ ZnEntity with: ( encodingBlock cull: resource cull: requestContext ) ofType: mediaType ] -{ #category : 'initialization' } +{ #category : #initialization } ResourceEncodingRule >> initializeMapping: aMediaType using: anEncodingBlock [ encodingBlock := anEncodingBlock. diff --git a/source/Stargate-Model/ResourceLocator.class.st b/source/Stargate-Model/ResourceLocator.class.st index 9b46506..45a5714 100644 --- a/source/Stargate-Model/ResourceLocator.class.st +++ b/source/Stargate-Model/ResourceLocator.class.st @@ -2,8 +2,8 @@ I'm responsible for locating specific resource instances and generating location urls from them " Class { - #name : 'ResourceLocator', - #superclass : 'ResourceLocatorBehavior', + #name : #ResourceLocator, + #superclass : #ResourceLocatorBehavior, #instVars : [ 'baseUrl', 'endpoint', @@ -11,18 +11,16 @@ Class { 'locationResolverBinding', 'exceptionHandler' ], - #category : 'Stargate-Model-Controllers', - #package : 'Stargate-Model', - #tag : 'Controllers' + #category : 'Stargate-Model-Controllers' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } ResourceLocator class >> handling: aStringOrSymbol [ ^ self handling: aStringOrSymbol extractingIdentifierWith: [ :httpRequest | '' ] ] -{ #category : 'instance creation' } +{ #category : #'instance creation' } ResourceLocator class >> handling: aStringOrSymbol calculatingLocationWith: aLocationResolver andIdentifierBy: aBlock [ ^ self @@ -31,7 +29,7 @@ ResourceLocator class >> handling: aStringOrSymbol calculatingLocationWith: aLoc andIdentifierBy: aBlock ] -{ #category : 'instance creation' } +{ #category : #'instance creation' } ResourceLocator class >> handling: aStringOrSymbol extractingIdentifierWith: aBlock [ ^ self @@ -40,7 +38,7 @@ ResourceLocator class >> handling: aStringOrSymbol extractingIdentifierWith: aBl andIdentifierBy: aBlock ] -{ #category : 'private' } +{ #category : #private } ResourceLocator class >> handling: aStringOrSymbol resolvingLocationWith: aLocationResolverBinding andIdentifierBy: aBlock [ ^ self new @@ -49,49 +47,49 @@ ResourceLocator class >> handling: aStringOrSymbol resolvingLocationWith: aLocat andIdentifierBy: aBlock ] -{ #category : 'accessing' } +{ #category : #accessing } ResourceLocator >> baseUrl [ ^ baseUrl ] -{ #category : 'accessing' } +{ #category : #accessing } ResourceLocator >> baseUrl: aServerUrl [ baseUrl := aServerUrl asUrl ] -{ #category : 'testing' } +{ #category : #testing } ResourceLocator >> canLookupResources [ ^ locationResolverBinding isDefined ] -{ #category : 'accessing' } +{ #category : #accessing } ResourceLocator >> endpoint [ ^ endpoint ] -{ #category : 'private' } +{ #category : #private } ResourceLocator >> exceptionHandler [ ^ exceptionHandler ] -{ #category : 'accessing' } +{ #category : #accessing } ResourceLocator >> handleExceptionsWith: anExceptionHandler [ exceptionHandler := anExceptionHandler ] -{ #category : 'private' } +{ #category : #private } ResourceLocator >> identifierLookupAction [ ^ identifierLookupAction ] -{ #category : 'initialization' } +{ #category : #initialization } ResourceLocator >> initializeHandling: aStringOrSymbol resolvingLocationWith: aLocationResolverBinding andIdentifierBy: aBlock [ baseUrl := '' asUrl. @@ -101,7 +99,7 @@ ResourceLocator >> initializeHandling: aStringOrSymbol resolvingLocationWith: aL exceptionHandler := RESTfulRequestExceptionHandler new ] -{ #category : 'querying' } +{ #category : #querying } ResourceLocator >> locationOf: resource within: requestContext [ ^ self baseUrl / endpoint asUrl diff --git a/source/Stargate-Model/ResourceLocatorBehavior.class.st b/source/Stargate-Model/ResourceLocatorBehavior.class.st index 5503ba1..e1952c5 100644 --- a/source/Stargate-Model/ResourceLocatorBehavior.class.st +++ b/source/Stargate-Model/ResourceLocatorBehavior.class.st @@ -1,60 +1,58 @@ Class { - #name : 'ResourceLocatorBehavior', - #superclass : 'Object', - #category : 'Stargate-Model-Controllers', - #package : 'Stargate-Model', - #tag : 'Controllers' + #name : #ResourceLocatorBehavior, + #superclass : #Object, + #category : 'Stargate-Model-Controllers' } -{ #category : 'accessing' } +{ #category : #accessing } ResourceLocatorBehavior >> baseUrl [ ^ self subclassResponsibility ] -{ #category : 'accessing' } +{ #category : #accessing } ResourceLocatorBehavior >> baseUrl: aServerUrl [ self subclassResponsibility ] -{ #category : 'testing' } +{ #category : #testing } ResourceLocatorBehavior >> canLookupResources [ self subclassResponsibility ] -{ #category : 'accessing' } +{ #category : #accessing } ResourceLocatorBehavior >> endpoint [ ^ self subclassResponsibility ] -{ #category : 'private' } +{ #category : #private } ResourceLocatorBehavior >> exceptionHandler [ ^ self subclassResponsibility ] -{ #category : 'accessing' } +{ #category : #accessing } ResourceLocatorBehavior >> handleExceptionsWith: anExceptionHandler [ self subclassResponsibility ] -{ #category : 'private' } +{ #category : #private } ResourceLocatorBehavior >> identifierLookupAction [ ^ self subclassResponsibility ] -{ #category : 'querying' } +{ #category : #querying } ResourceLocatorBehavior >> locationOf: resource within: requestContext [ self subclassResponsibility ] -{ #category : 'querying' } +{ #category : #querying } ResourceLocatorBehavior >> lookupResourceIdentifiedBy: httpRequest evaluating: aQueryBlock [ ^ self exceptionHandler diff --git a/source/Stargate-Model/ResourceRESTfulController.class.st b/source/Stargate-Model/ResourceRESTfulController.class.st index 1f2c763..0011e93 100644 --- a/source/Stargate-Model/ResourceRESTfulController.class.st +++ b/source/Stargate-Model/ResourceRESTfulController.class.st @@ -5,38 +5,33 @@ My subclasses must create one or more RESTfulRequestHandler (usually with the av and delegate to them the needed methods. " Class { - #name : 'ResourceRESTfulController', - #superclass : 'Object', - #category : 'Stargate-Model-Controllers', - #package : 'Stargate-Model', - #tag : 'Controllers', - #'gs_options' : [ - 'dbTransient' - ] + #name : #ResourceRESTfulController, + #superclass : #Object, + #category : 'Stargate-Model-Controllers' } -{ #category : 'testing' } +{ #category : #testing } ResourceRESTfulController class >> isAbstract [ ^ self = ResourceRESTfulController ] -{ #category : 'asserting' } +{ #category : #asserting } ResourceRESTfulController >> assert: httpRequest isAuthorizedTo: permission within: requestContext [ ( requestContext includesPermission: permission ) ifFalse: [ httpRequest abort: ZnResponse forbidden ] ] -{ #category : 'private' } +{ #category : #private } ResourceRESTfulController >> jsonMediaType: aSubType vendoredBy: aVendorName version: aVersion [ ^ ( 'application/vnd.<1s>.<2s>+json' expandMacrosWith: aVendorName with: aSubType ) asMediaType version: aVersion ] -{ #category : 'accessing' } +{ #category : #accessing } ResourceRESTfulController >> routes [ ^ (UnaryMessageSendingCollector @@ -45,7 +40,7 @@ ResourceRESTfulController >> routes [ to: self) value ] -{ #category : 'configuring' } +{ #category : #configuring } ResourceRESTfulController >> serverUrl: aServerUrl [ self subclassResponsibility diff --git a/source/Stargate-Model/RouteConfigurator.class.st b/source/Stargate-Model/RouteConfigurator.class.st index fe7a5a7..66714e6 100644 --- a/source/Stargate-Model/RouteConfigurator.class.st +++ b/source/Stargate-Model/RouteConfigurator.class.st @@ -4,31 +4,29 @@ I'm a web service route configurator. I'm being used to configure a route on a Teapot server. I also know how to configure a route supporting cross-origin resource sharing. " Class { - #name : 'RouteConfigurator', - #superclass : 'Object', + #name : #RouteConfigurator, + #superclass : #Object, #instVars : [ 'teapot', 'resourceController' ], - #category : 'Stargate-Model-Routing', - #package : 'Stargate-Model', - #tag : 'Routing' + #category : 'Stargate-Model-Routing' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } RouteConfigurator class >> configuring: aTeapot withRoutesDefinedOn: aResourceRESTfulController [ ^ self new initializeConfiguring: aTeapot withRoutesDefinedOn: aResourceRESTfulController ] -{ #category : 'configuring' } +{ #category : #configuring } RouteConfigurator >> configure [ resourceController routes do: [ :routeSpecification | routeSpecification configureUsing: self ] ] -{ #category : 'private - configuring' } +{ #category : #'private - configuring' } RouteConfigurator >> configureRouteFrom: aRouteSpecification [ teapot addRouteMatchedBy: aRouteSpecification asRequestMatcher action: [ :request | @@ -37,7 +35,7 @@ RouteConfigurator >> configureRouteFrom: aRouteSpecification [ ] ] -{ #category : 'initialization' } +{ #category : #initialization } RouteConfigurator >> initializeConfiguring: aTeapot withRoutesDefinedOn: aResourceRESTfulController [ teapot := aTeapot. @@ -45,7 +43,7 @@ RouteConfigurator >> initializeConfiguring: aTeapot withRoutesDefinedOn: aResour self withServerUrlDo: [ :url | resourceController serverUrl: url ]. ] -{ #category : 'private - configuring' } +{ #category : #'private - configuring' } RouteConfigurator >> withServerUrlDo: aBlock [ teapot server serverUrl ifNotNil: aBlock diff --git a/source/Stargate-Model/RouteSpecification.class.st b/source/Stargate-Model/RouteSpecification.class.st index ccb02bf..2982eed 100644 --- a/source/Stargate-Model/RouteSpecification.class.st +++ b/source/Stargate-Model/RouteSpecification.class.st @@ -3,32 +3,30 @@ I'm an spec for a route. I provide a URL template, an HTTP method and a handler to invoke for this route. " Class { - #name : 'RouteSpecification', - #superclass : 'Object', + #name : #RouteSpecification, + #superclass : #Object, #instVars : [ 'httpMethod', 'handler', 'urlTemplate' ], - #category : 'Stargate-Model-Routing', - #package : 'Stargate-Model', - #tag : 'Routing' + #category : 'Stargate-Model-Routing' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } RouteSpecification class >> handling: anHttpMethod at: anUrlTemplate evaluating: aBlock [ ^ self new initializeHandling: anHttpMethod at: anUrlTemplate evaluating: aBlock ] -{ #category : 'converting' } +{ #category : #converting } RouteSpecification >> asRequestMatcher [ ^ TeaRequestMatcher method: ( TeaMethodMatcher exactly: httpMethod asSymbol ) url: urlTemplate asTeaUrlPattern ] -{ #category : 'configuring' } +{ #category : #configuring } RouteSpecification >> authenticatedBy: anAuthorizationFilter [ ^ self class @@ -40,25 +38,25 @@ RouteSpecification >> authenticatedBy: anAuthorizationFilter [ ] ] -{ #category : 'configuring' } +{ #category : #configuring } RouteSpecification >> configureUsing: aRouteConfigurator [ aRouteConfigurator configureRouteFrom: self ] -{ #category : 'accessing' } +{ #category : #accessing } RouteSpecification >> handler [ ^ handler ] -{ #category : 'accessing' } +{ #category : #accessing } RouteSpecification >> httpMethod [ ^ httpMethod ] -{ #category : 'initialization' } +{ #category : #initialization } RouteSpecification >> initializeHandling: anHttpMethod at: anURLTemplate evaluating: aBlock [ httpMethod := anHttpMethod. @@ -69,7 +67,7 @@ RouteSpecification >> initializeHandling: anHttpMethod at: anURLTemplate evaluat ] ] -{ #category : 'accessing' } +{ #category : #accessing } RouteSpecification >> urlTemplate [ ^ urlTemplate diff --git a/source/Stargate-Model/SingleResourceRESTfulController.class.st b/source/Stargate-Model/SingleResourceRESTfulController.class.st index 86d9811..4324f91 100644 --- a/source/Stargate-Model/SingleResourceRESTfulController.class.st +++ b/source/Stargate-Model/SingleResourceRESTfulController.class.st @@ -2,39 +2,37 @@ I'm a RESTful controllers handling only one resource, so I can make some assumptions and provide some ready to use behavior. " Class { - #name : 'SingleResourceRESTfulController', - #superclass : 'ResourceRESTfulController', - #category : 'Stargate-Model-Controllers', - #package : 'Stargate-Model', - #tag : 'Controllers' + #name : #SingleResourceRESTfulController, + #superclass : #ResourceRESTfulController, + #category : 'Stargate-Model-Controllers' } -{ #category : 'testing' } +{ #category : #testing } SingleResourceRESTfulController class >> isAbstract [ ^ self = SingleResourceRESTfulController ] -{ #category : 'private' } +{ #category : #private } SingleResourceRESTfulController >> endpoint [ ^ self requestHandler endpoint ] -{ #category : 'private' } +{ #category : #private } SingleResourceRESTfulController >> identifierIn: httpRequest [ ^ httpRequest at: self identifierKey ] -{ #category : 'private' } +{ #category : #private } SingleResourceRESTfulController >> identifierKey [ ^ #identifier asString ] -{ #category : 'private' } +{ #category : #private } SingleResourceRESTfulController >> identifierTemplate [ ^ '<1s>/%<<2s>:<3s>>' @@ -43,19 +41,19 @@ SingleResourceRESTfulController >> identifierTemplate [ with: self typeIdConstraint asString ] -{ #category : 'private' } +{ #category : #private } SingleResourceRESTfulController >> requestHandler [ ^ self subclassResponsibility ] -{ #category : 'configuring' } +{ #category : #configuring } SingleResourceRESTfulController >> serverUrl: aServerUrl [ self requestHandler serverUrl: aServerUrl ] -{ #category : 'private' } +{ #category : #private } SingleResourceRESTfulController >> typeIdConstraint [ ^ self subclassResponsibility diff --git a/source/Stargate-Model/SubresourceLocator.class.st b/source/Stargate-Model/SubresourceLocator.class.st index 53482b3..ffb52cf 100644 --- a/source/Stargate-Model/SubresourceLocator.class.st +++ b/source/Stargate-Model/SubresourceLocator.class.st @@ -2,8 +2,8 @@ I'm responsible for locating specific subresource instances and generating location urls from them " Class { - #name : 'SubresourceLocator', - #superclass : 'ResourceLocatorBehavior', + #name : #SubresourceLocator, + #superclass : #ResourceLocatorBehavior, #instVars : [ 'endpoint', 'identifierLookupAction', @@ -11,12 +11,10 @@ Class { 'resourceLocator', 'exceptionHandler' ], - #category : 'Stargate-Model-Controllers', - #package : 'Stargate-Model', - #tag : 'Controllers' + #category : 'Stargate-Model-Controllers' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } SubresourceLocator class >> handling: aStringOrSymbol calculatingLocationWith: aLocationResolver andIdentifierBy: aBlock @@ -29,7 +27,7 @@ SubresourceLocator class >> handling: aStringOrSymbol locatingParentResourceWith: aResourceLocator ] -{ #category : 'instance creation' } +{ #category : #'instance creation' } SubresourceLocator class >> handling: aStringOrSymbol extractingIdentifierWith: aBlock locatingParentResourceWith: aResourceLocator [ ^ self @@ -39,7 +37,7 @@ SubresourceLocator class >> handling: aStringOrSymbol extractingIdentifierWith: locatingParentResourceWith: aResourceLocator ] -{ #category : 'private' } +{ #category : #private } SubresourceLocator class >> handling: aStringOrSymbol resolvingLocationWith: aLocationResolverBinding andIdentifierBy: aBlock @@ -52,49 +50,49 @@ SubresourceLocator class >> handling: aStringOrSymbol locatingParentResourceWith: aResourceLocator ] -{ #category : 'accessing' } +{ #category : #accessing } SubresourceLocator >> baseUrl [ ^ resourceLocator baseUrl ] -{ #category : 'accessing' } +{ #category : #accessing } SubresourceLocator >> baseUrl: aServerUrl [ resourceLocator baseUrl: aServerUrl ] -{ #category : 'testing' } +{ #category : #testing } SubresourceLocator >> canLookupResources [ ^ locationResolverBinding isDefined ] -{ #category : 'accessing' } +{ #category : #accessing } SubresourceLocator >> endpoint [ ^ endpoint ] -{ #category : 'private' } +{ #category : #private } SubresourceLocator >> exceptionHandler [ ^ exceptionHandler ] -{ #category : 'accessing' } +{ #category : #accessing } SubresourceLocator >> handleExceptionsWith: anExceptionHandler [ exceptionHandler := anExceptionHandler ] -{ #category : 'private' } +{ #category : #private } SubresourceLocator >> identifierLookupAction [ ^ identifierLookupAction ] -{ #category : 'initialization' } +{ #category : #initialization } SubresourceLocator >> initializeHandling: aStringOrSymbol resolvingLocationWith: aLocationResolverBinding andIdentifierBy: aBlock @@ -107,7 +105,7 @@ SubresourceLocator >> initializeHandling: aStringOrSymbol exceptionHandler := RESTfulRequestExceptionHandler new ] -{ #category : 'querying' } +{ #category : #querying } SubresourceLocator >> locationOf: resource within: requestContext [ ^ ( resourceLocator locationOf: requestContext parentResource within: requestContext ) diff --git a/source/Stargate-Model/WebOrigin.class.st b/source/Stargate-Model/WebOrigin.class.st index 5b5cfd3..3157281 100644 --- a/source/Stargate-Model/WebOrigin.class.st +++ b/source/Stargate-Model/WebOrigin.class.st @@ -12,17 +12,15 @@ References https://tools.ietf.org/html/rfc3986 " Class { - #name : 'WebOrigin', - #superclass : 'Object', + #name : #WebOrigin, + #superclass : #Object, #instVars : [ 'url' ], - #category : 'Stargate-Model-CORS', - #package : 'Stargate-Model', - #tag : 'CORS' + #category : 'Stargate-Model-CORS' } -{ #category : 'instance creation' } +{ #category : #'instance creation' } WebOrigin class >> basedOn: aUrl [ AssertionChecker @@ -33,7 +31,7 @@ WebOrigin class >> basedOn: aUrl [ ^ self new initializeBasedOn: aUrl ] -{ #category : 'preconditions' } +{ #category : #preconditions } WebOrigin class >> hasValidOrigin: aUrl [ | validOriginSchemes | @@ -43,43 +41,43 @@ WebOrigin class >> hasValidOrigin: aUrl [ ^ aUrl hasScheme and: [ ( validOriginSchemes includes: aUrl scheme ) and: [ aUrl hasHost ] ] ] -{ #category : 'comparing' } +{ #category : #comparing } WebOrigin >> = aWebOrigin [ ^ self asString = aWebOrigin asString ] -{ #category : 'converting' } +{ #category : #converting } WebOrigin >> asString [ ^ self printString ] -{ #category : 'converting' } +{ #category : #converting } WebOrigin >> asUrl [ ^ url copy ] -{ #category : 'converting' } +{ #category : #converting } WebOrigin >> asWebOrigin [ ^ self ] -{ #category : 'comparing' } +{ #category : #comparing } WebOrigin >> hash [ ^ self asString hash ] -{ #category : 'initialization' } +{ #category : #initialization } WebOrigin >> initializeBasedOn: aUrl [ url := aUrl ] -{ #category : 'printing' } +{ #category : #printing } WebOrigin >> printOn: stream [ stream diff --git a/source/Stargate-Model/ZnAuthenticationFilter.class.st b/source/Stargate-Model/ZnAuthenticationFilter.class.st index f463efa..c6b1ecf 100644 --- a/source/Stargate-Model/ZnAuthenticationFilter.class.st +++ b/source/Stargate-Model/ZnAuthenticationFilter.class.st @@ -2,17 +2,15 @@ I'm an authentication filter supporting the already provided ZnAuthenticators: ZnBasicAuthenticator or ZnDigestAuthenticator " Class { - #name : 'ZnAuthenticationFilter', - #superclass : 'AuthenticationFilter', + #name : #ZnAuthenticationFilter, + #superclass : #AuthenticationFilter, #instVars : [ 'authenticator' ], - #category : 'Stargate-Model-Auth', - #package : 'Stargate-Model', - #tag : 'Auth' + #category : 'Stargate-Model-Auth' } -{ #category : 'private' } +{ #category : #private } ZnAuthenticationFilter class >> canHandle: configuration [ | schema | @@ -21,7 +19,7 @@ ZnAuthenticationFilter class >> canHandle: configuration [ ^ schema = 'basic' ] -{ #category : 'private' } +{ #category : #private } ZnAuthenticationFilter class >> configuredBy: configuration [ ^ self @@ -29,32 +27,32 @@ ZnAuthenticationFilter class >> configuredBy: configuration [ password: ( configuration at: #authPassword ifAbsent: [ AssertionFailed signal: 'Missing password' ] ) ] -{ #category : 'instance creation' } +{ #category : #'instance creation' } ZnAuthenticationFilter class >> username: username password: password [ ^ self using: ( ZnBasicAuthenticator username: username password: password ) ] -{ #category : 'instance creation' } +{ #category : #'instance creation' } ZnAuthenticationFilter class >> using: aZnAuthenticator [ ^ self new initializeUsing: aZnAuthenticator ] -{ #category : 'accessing' } +{ #category : #accessing } ZnAuthenticationFilter >> authChallenge [ ^ authenticator authHeader ] -{ #category : 'private' } +{ #category : #private } ZnAuthenticationFilter >> checkCredentials: authorization for: httpRequest within: requestContext ifInvalid: aBlock [ ( authenticator isRequestAuthenticated: httpRequest ) ifFalse: aBlock ] -{ #category : 'initialization' } +{ #category : #initialization } ZnAuthenticationFilter >> initializeUsing: anAuthenticator [ authenticator := anAuthenticator diff --git a/source/Stargate-Model/package.st b/source/Stargate-Model/package.st index 3b49133..023767a 100644 --- a/source/Stargate-Model/package.st +++ b/source/Stargate-Model/package.st @@ -1 +1 @@ -Package { #name : 'Stargate-Model' } +Package { #name : #'Stargate-Model' }