Jump to content
Sign in to follow this  
  • entries
  • comments
  • views

Some Experimentation

Sign in to follow this  
Colin Jeanne


Just a short bit of what I've been playing with recently.

I still work on my CMS off and on and recently I've been experimenting with REST. In my old design each module had a function called GetContent() which would be passed an array of POST variables and an array of parameters coming from the URI. The problem with this design is that I needed to do all my form processing in some large and nasty function which basically left me unsatisfied with my entire system. I also ran into some chicken-vs.-egg problems when installing modules.

This is my new system:

I've gotten rid of the GetContent() function. Instead, during installation, modules can register handlers for specific HTTP methods on given URIs. For example, my administration module registers a handler for GET on /members/*, /modules/, PUT on /widgets/, and DELETE on /members/* (among other things). GET on /members/ will get a page listing the registered members on my site. You can be more specific and GET /members/Colin%20Jeanne/ and it will get my profile. PUT on /widgets/ will change the display order of the widgets. DELETE on /members/Colin%20Jeanne/ will delete my user account.

Each URI/HTTP method pair is associated with a callback function which handles it and is passed the rest of the URI as extra parameters. For example, GET on /members/Colin%20Jeanne/ is handled by the function that handles all GETs on /members/* and "Colin Jeanne" is the parameter of the function.

I like this system by there are some kinks to work out. Firstly, I like the use of PUT and DELETE but these seem difficult to use in HTML forms - PUT especially. I would like to have the content of a PUT message be an XML fragment but HTML forms dont really allow me to specify what is sent. I could easily set it up in javascript but I'd like my site to also work for users with javascript turned off.

Hmmm... I'll definitely need to experiment more during winter break.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!