Skip to content
October 12, 2012 / edeustace

My first play plugin: Mongo Rest Layer

I’ve been working on an internal project where we needed a quick and easy way to interact with a mongo db over rest. Mongolab.com has an existing rest layer that does this, but we wanted to route it through our Play! 2 app.

So I created a Play! plugin called Mongo Rest Layer. Its a simple library that adds REST capabilities to your play app with little setup. You just need to pass in a mongo uri and override the onRouteRequest method of GlobalSettings. The REST behaviour is modelled on the mongolab.com api, but you can add your own flavour by implementing: brokers.RequestBroker.

May be of use to others.

 

Advertisements

2 Comments

Leave a Comment
  1. James Corbett / Oct 12 2012 8:54 pm

    Could you explain your use case? Why would you emulate an existing endpoint? Is it a scaling thing to move the load somewhere else or … ?

    • edeustace / Oct 13 2012 1:38 pm

      Hi James,
      The use case would be mainly for prototyping. You have a mongo db and you’re building a new app with play, adding the plugin gives you a rest api ready to roll.

      So it’s nothing to do with scaling.

      The api is based on mongo labs but you’re db maybe elsewhere – on your dev machine for example.
      Ed

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: