forked from ostinelli/gin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Json encode all controllers responses
- Loading branch information
Showing
5 changed files
with
61 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
local MessagesController = {} | ||
|
||
function MessagesController:index() | ||
return 'Index of messages for user: ' .. self.params.user_id | ||
return { recipient = self.params.user_id, messages = { 'abc' } } | ||
end | ||
|
||
function MessagesController:show() | ||
return 'Messages with id: ' .. self.params.id .. ' of user: ' .. self.params.user_id | ||
return { message = { id = self.params.id, recipient = self.params.user_id, body = "Ralis is awesome." } } | ||
end | ||
|
||
return MessagesController |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
local UsersController = {} | ||
|
||
function UsersController:index() | ||
return 'Index of Users!' | ||
return { users = { 'roberto' } } | ||
end | ||
|
||
function UsersController:show() | ||
return 'Page of user with id: ' .. self.params.id | ||
return { name = self.params.id } | ||
end | ||
|
||
return UsersController |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters