Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed JSON bug and made a short explanation about API #3

Merged
merged 4 commits into from Aug 6, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ If you want to run the site on a different port, use the -p parameter.

bundle exec rails server -p 80

## API

You can generate passwords through an API, if you want to automate creation, it is done by hitting the password action with a POST-request. In the development environment you can use this address: http://127.0.0.1:3000/passwords.json

And you will have to send these POST variables:

password[payload]: test

password[expire_after_days]: 60

password[expire_after_views]: 1337

You can test it in your browsers javascript console by going to the frontpage of Password Pusher and type:

$.post('http://127.0.0.1:3000/passwords.json',{ 'password[payload]': 'test', 'password[expire_after_days]': '60', 'password[expire_after_views]': '1337' }, function(data) { alert(data.url_token) } )

Or do it with curl:

curl -d -X POST --data "password[payload]=payload&password[expire_after_days]=60&password[expire_after_views]=1337" http://127.0.0.1:3000/passwords.json

## Potential Quick Start Errors

### Command not found: bundle
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/passwords_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def create
respond_to do |format|
if @password.save
format.html { redirect_to "/p/#{@password.url_token}", :notice => "The password has been pushed." }
format.json { render :json => @password, :status => :created, :location => @password }
format.json { render :json => @password, :status => :created }
else
format.html { render :action => "new" }
format.json { render :json => @password.errors, :status => :unprocessable_entity }
Expand Down
1 change: 1 addition & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
Expand Down