Address >> descriptionStreet
^ MAStringDescription new
autoAccessor: #street;
label: 'Street';
priority: 100
Address >> descriptionPlz
^ MANumberDescription new
autoAccessor: #plz;
priority: 200; label: 'PLZ';
beRequired;
min: 1000;
max: 9999
anAddress description do: [ :description |
Transcript
show: description label; show: ':'; tab;
show: (description toString: (anAddress readUsing: description));
cr ]
Street: Schutzenmattstrasse
PLZ: 3012
Place: Bern
Canton: Bern
self call: (anAddress asComponent addValidatedForm; yourself)
WARestfulFilter subclass: #TBRestfulFilter
instanceVariableNames: ''
classVariableNames: ''
package: 'TinyBlog-REST'
TBApplicationRootComponent class >> initialize
"self initialize"
| app |
app := WAAdmin register: self asApplicationAt: 'TinyBlog'.
app
addLibrary: JQDeploymentLibrary;
addLibrary: JQUiDeploymentLibrary;
addLibrary: TBSDeploymentLibrary.
app addFilter: TBRestfulFilter new.
TBRestfulFilter >> listAll
<get>
<produces: 'text/json'>
^ String streamContents: [ :astream |
TBBlog current allBlogPosts
do: [ :each | each javascriptOn: stream ]
separatedBy: [ stream << ',' ] ]
TBRestfulFilter >> post: title
<get>
<path: 'post/{title}'>
<produces: 'text/json'>
| post |
post := TBBlog current postWithTitle: title.
post ifNil: [ ^ self notFound ].
^ String streamContents: [ :astream |
post javascriptOn: astream ]
TBRestfulFilter >> search: title
<get>
<path: 'search?title={title}'>
<produces: 'text/json'>
| post |
post := TBBlog current postWithTitle: title.
post ifNil: [ ^ self notFound ].
^ String streamContents: [ :astream |
post javascriptOn: astream attributes: #(title category date text) ]
http://localhost:8080/TinyBlog/search?title=Welcome%20in%20TinyBlog
/