Skip to content

Commit

Permalink
changed example, added @JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
warmuuh committed Apr 5, 2013
1 parent 2bf0d4a commit c7a49d4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
15 changes: 6 additions & 9 deletions express-example/MyService.js
Expand Up @@ -9,16 +9,13 @@ MyService.prototype = {
return 'index'; return 'index';
}, },


test: function (name, id)/*@POST("/test/:id") @Param*/ { submit: function (name, age)/*@POST @Param*/ {
return {view:'test', model:{name: name, id: id}}; var msg = (age < 18)? "You are too young" : "You are welcome!";
}, return {view:'greet', model:{name: name, msg: msg}};


rest: function( /*@Body*/msg,
/*@Param*/id,
/*@Autowired*/test)
/*@POST("/rest/:id") @Body*/ {
return {msg: msg, id: id, wired: test};
} }


}; };




Expand Down
7 changes: 7 additions & 0 deletions express-example/views/greet.jade
@@ -0,0 +1,7 @@
html
head
body
h1|Hello, #{name}!
p=msg


6 changes: 5 additions & 1 deletion express-example/views/index.jade
Expand Up @@ -3,7 +3,11 @@ html
body body
h1|Hello, what is your name? h1|Hello, what is your name?
div div
form(name="input", action='/test/1',method='post') form(name="input", action='/submit',method='post')
label(for='name') Name label(for='name') Name
input(id='name', name="name",type='text',value='',placeholder='Type your name') input(id='name', name="name",type='text',value='',placeholder='Type your name')

label(for='age') Age
input(id='age', name="age",type='text',value='',placeholder='Type your age')

input(type='submit',value='Send!') input(type='submit',value='Send!')
9 changes: 0 additions & 9 deletions express-example/views/test.jade

This file was deleted.

4 changes: 3 additions & 1 deletion yaap/wire/express/plugins/VerbProcessors.js
Expand Up @@ -82,8 +82,10 @@ function(when, _) {




function processResponse(result, res, fnDescription, context){ function processResponse(result, res, fnDescription, context){
//raw json? //raw?
if (getAnnotation(fnDescription, "@Body") !== undefined){ if (getAnnotation(fnDescription, "@Body") !== undefined){
res.send(result);
} else if (getAnnotation(fnDescription, "@JSON") !== undefined){
res.json(result); res.json(result);
} else { //forwarding to view } else { //forwarding to view
if (typeof result === 'string') if (typeof result === 'string')
Expand Down

0 comments on commit c7a49d4

Please sign in to comment.