Skip to content

Commit

Permalink
Merge d3517c4 into 0bfa2e1
Browse files Browse the repository at this point in the history
  • Loading branch information
essal0815 committed Jul 4, 2018
2 parents 0bfa2e1 + d3517c4 commit 7f1a40f
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 8 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interaction
preHook: anEnv

^ self
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"class" : {
},
"instance" : {
"preHook:" : "lj 7/4/2018 12:26" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "RatPack-Testing",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"name" : "RPAntiPreHookConventionMiddleware",
"pools" : [
],
"super" : "RPTestMiddleware",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interaction
assertedPreHookResult: aPreHookResult

((aPreHookResult respondsTo: #ifTrue:) and: [ (aPreHookResult respondsTo: #ifFalse:). ])
ifTrue: [ ^ aPreHookResult ]
ifFalse: [ self error: 'preHook of: ' , self name , ' has to return true or false.' ]
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ accessing-default
handle: anEnv next: aNext

(self isUrlBlacklisted: anEnv request url)
ifTrue: [ ^ aNext value].
ifTrue: [ ^ aNext value ].

(self preHook: anEnv)
(self assertedPreHookResult: (self preHook: anEnv))
ifTrue: [ aNext value.
self postHook: anEnv.].
self postHook: anEnv. ].

Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
interaction
postHook: anEnv
postHook: anEnv

"Called after handler execution"
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
interaction
preHook: anEnv

" return true if you want to continue handling this request. Return false if the handling should be aborted."
"Called before handler execution. Return value must understand #ifTrue: or #ifFalse:
Return true if you want to continue handling this request.
Return false if the handling should be aborted. (Post Hook is not called.)"

^ true
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"class" : {
"blacklist" : "re 6/26/2018 12:00" },
"instance" : {
"handle:next:" : "lj 5/25/2018 19:34",
"assertedPreHookResult:" : "lj 7/4/2018 14:17",
"handle:next:" : "lj 7/4/2018 13:07",
"isUrlBlacklisted:" : "lj 5/25/2018 19:45",
"postHook:" : "re 6/20/2018 22:08",
"preHook:" : "re 6/20/2018 22:09" } }
"postHook:" : "lj 7/4/2018 11:56",
"preHook:" : "lj 7/4/2018 14:09" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test - database - postgresql
testMiddlewarePreHookConvention

| middleware |
middleware := RPAntiPreHookConventionMiddleware new.
self assert: (middleware assertedPreHookResult: true) equals: true.
self assert: (middleware assertedPreHookResult: false) equals: false.
self assert: ([middleware assertedPreHookResult: (middleware preHook: nil). false] on: Error do: [true])
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"testMiddlewareCallChainInterrupt" : "lj 5/25/2018 20:59",
"testMiddlewareCallChainOrder" : "lj 5/25/2018 19:04",
"testMiddlewareInstanciation" : "lj 5/22/2018 15:14",
"testMiddlewarePreHookConvention" : "lj 7/4/2018 14:15",
"testMiddlewarePreHookFalse" : "lj 5/30/2018 15:02",
"testMiddlewarePreHookTrue" : "lj 5/30/2018 15:02",
"testModelNameToSnakeCase" : "jm 5/23/2018 15:52",
Expand Down

0 comments on commit 7f1a40f

Please sign in to comment.