Skip to content

Commit

Permalink
routesDeclaration is now reflective and based on pragmas to define th…
Browse files Browse the repository at this point in the history
…e routes at startup
  • Loading branch information
sebastianconcept committed Feb 26, 2024
1 parent 78cff44 commit 6803f14
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Ride/Ride.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ Ride class >> allowsLoglevel: aSymbol [

{ #category : #actions }
Ride class >> beDevEnvironment [

"Sets the OS environment to be in #DEVELOPMENT mode"

<script>
Smalltalk os environment at: 'MODE' put: #DEVELOPMENT
]

Expand Down Expand Up @@ -134,24 +134,25 @@ Ride class >> mode [

{ #category : #actions }
Ride class >> purgeUploadsDirectory [

"Removes all files from the uploads directory"

RideDirectoryResolver uploadsDirectory files do: [ :each |
<script>
self resource uploadsDirectory asFileReference files do: [ :each |
each delete ]
]

{ #category : #actions }
Ride class >> reset [

<script>
| released |
service ifNotNil: [
service ifNotNil: [
released := service.
service := nil ].
logLevelSymbols := nil.
isMaintenance := nil.
RideDeclarativeRouting reset.
resource ifNotNil: [
resource ifNotNil: [
Ride isDevelopment ifTrue: [ resource resetAssetsMapFile ].
resource reset ]
]
Expand Down Expand Up @@ -202,6 +203,7 @@ Ride class >> shutDown [
{ #category : #actions }
Ride class >> start [

<script>
service start
]

Expand All @@ -222,5 +224,6 @@ Ride class >> startUp [
{ #category : #actions }
Ride class >> stop [

<script>
service ifNotNil: [ service stop ]
]
24 changes: 24 additions & 0 deletions Ride/RideServer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,30 @@ RideServer >> router [
^ router ifNil: [ self initializeRouter ]
]

{ #category : #accessing }
RideServer >> routesDeclaration [
"Answer all the route definitions for this service."

| all |
all := OrderedCollection new.

(self routesDeclarationFromPragma: #rideRoutes) do: [
:routeDefinitions | all addAll: routeDefinitions ].

all addAll: (self routesDeclarationFromPragma: #rideRoute).

^ all
]

{ #category : #accessing }
RideServer >> routesDeclarationFromPragma: aSymbol [
"Collect all the routes definitions found using aSymbol as pragma."

^ (PragmaCollector filter: [ :prg | prg selector = aSymbol ]) reset
collected collect: [ :pragma |
pragma method origin soleInstance perform: pragma method selector ]
]

{ #category : #actions }
RideServer >> run: aWebSocket with: aBlock [
^ [ [ | message |
Expand Down

0 comments on commit 6803f14

Please sign in to comment.