Skip to content

dergraf/httptimer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

======================
httptimer Application:
======================
Schedules HTTP Requests using a simple JSON API.
httptimer depends on webmachine, ibrowse, and Erlang/OTP of course.


How to use the JSON API of httptimer using curl
===============================================
Please consider the following conventions:
<<key>> == Your API key
<<time>> == The unix timestamp when you want to schedule the HTTP request (as integer)
<<timerId>> == is returned from the PUT request
<<requestUrl>> == The url to request (as string)



1. Scheduling a new Timer
-------------------------
curl -X PUT -u username:password http://localhost:8000/timer/<<key>>
	-H "Content-type: application/json" 
	--data '{"url":"<<requestUrl>>, "method":"get", "headers":[], "time":<<time>>, "body":"hello world"}'

The PUT request returns a JSON object containing the <<timerId>> (e.g. {"timerId":"615E4CABA561394AD7D89CF29EE7AC72"})


2. Retrieving timer information
-------------------------------
curl -X GET -u username:password http://localhost:8000/timer/<<key>>/<<timerId>> 
	-H "Accept: application/json"

The GET request returns a JSON object similar to the following:
{"url":"http://localhost:8000/timer_test/post","time":1300904795,"created_on":1300738685,"headers":{},"method":"get","body":"hello world"}


3. Deleting a timer
-------------------
curl -X DELETE -u username:password http://localhost:8000/timer/<<key>>/<<timerId>>


How to use the JSON API of httptimer using jQuery
=================================================
Check out the dummy Test Application running on 
http://localhost:8000/timer_test



You should find in this directory:
==================================
README : this file
Makefile : simple make commands
rebar : the Rebar build tool for Erlang applications
rebar.config : configuration for Rebar
start.sh : simple startup script for running httptimer
/src
  /httptimer.app.src : the Erlang app specification / configuration
  /httptimer.erl : Startup module
  /httptimer_app.erl : base module for the Erlang application
  /httptimer_sup.erl : OTP supervisor for the application
  /httptimer_resource.erl : the httptimer Webmachine resource
  /httptimer.hrl : headerfile defining the Timer record
  /httptimer_helper.erl : helper functions
  /hex.erl : module for easier handling hex values
  /date_util.erl : helper functions for handling time and date
  /timer_manager.erl : httptimer Backend module
  /timer_store.erl : Mnesia Frontend Module
  /test_resource.erl : Webmachine resource used for testing
/priv
  /dispatch.conf : the Webmachine URL-dispatching table
/www
  /test.html : simple javascript test application

You probably want to do one of a couple of things at this point:

Build the httptimer application:
   $ make
   - or -
   $ ./rebar compile

Start up the httptimer application:
   $ ./start.sh

TODOs:
======
- The API key is unused at the moment. As a next step I will improve authentication, authorization and accounting.
- So far I tested the application manually using curl and jQuery, I would like to see this automated in the future.
- Currently you must provide the execution time as a Unix timestamp, in terms of usability this needs to be improved. Moreover httptimer does not yet support repetitive timers.

About

schedule your http requests

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages