Skip to content

Developer deep dive into Http API

keithwoodlock edited this page May 8, 2012 · 15 revisions

Developer deep dive into Http API

Introduction

One of the key enablers of the faster, lighter, cheaper approach behind this MIS over the existing version of mifos is the API.

Heres an overview of what its based on:

  1. The API is resource-oriented. Whilst not what some would view as full REST, it is a pragmatic approach.
  2. Its developer-oriented. The purpose of the API is to make the developer that uses it successful and productive.
  3. As such the API should be predictable and simple to learn and use

We can achieve this through:

  1. Resource URLs will be simple and intuitive
  2. JSON will be returned in all responses from the API, including errors

|Resource|POST (create)|GET(read)|PUT(update)|DELETE(delete)| |/loanproducts| create new loanproduct| list all loanproducts | bulk update loan products | delete all loan products |


Jersey setup

In mifosx we use Jersey and its support for integration with spring. see https://wikis.oracle.com/display/Jersey/Main

In the mifosngprovider/src/main/webapp/WEB-INF/web.xml you will see configuration for a servlet named jersey-serlvet that is mapped to /api/*. This allows for all requests that begin with /api to be routed through Jersey e.g. https://localhost:8085/mifosng-provider/api/v1/loanproducts

The support for com.sun.jersey.spi.spring.container.servlet.SpringServlet class used comes from Jerseys spring-integration project. See mifosngprovider/build.gradle for the dependencies.

Root resources