Ok, so I added support for sessions to http integration. It's based on very solid Go's gorilla/sessions. With it I made a simple login functionality and some typical functions you would need to provide a simple API for a browser based web-application.
The five functions of "web framework" remained the same as in the first post.
The Account-resource has many more methods now:
The page resource now has 3 more methods that require that the user is logined and that the page it sets or deletes is owned by that user.
If you want to delete a page and aren't logined, you get 401 status, if the page doesn't exist or isn't yours you get 403 - forbidden status and if the page is your you get status 200 and a number of affected pages back.
You can see the full code on github repository under examples/webapp_3. You need to compile Rye with psql and sqlite support.
Next I need to make validation failure return as JSON response to the client and make the signup functionality. Then it's almost ready to host a simple webapp I was planning to.
Komentarji
Objavite komentar