Skip to content

Commit e690f37

Browse files
author
Michael Bleigh
committed
Cleaning up the README a bit.
1 parent 01676ed commit e690f37

File tree

3 files changed

+25
-64
lines changed

3 files changed

+25
-64
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2009 Michael Bleigh
1+
Copyright (c) 2010 Michael Bleigh and Intridea, Inc.
22

33
Permission is hereby granted, free of charge, to any person obtaining
44
a copy of this software and associated documentation files (the

README.markdown

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,44 +19,57 @@ Grape APIs are Rack applications that are created by subclassing `Grape::API`. B
1919
def current_user
2020
@current_user ||= User.authorize!(env)
2121
end
22+
23+
def authenticate!
24+
error!('401 Unauthorized', 401) unless current_user
25+
end
2226
end
2327
2428
resource :statuses do
25-
formats :rss, :atom
26-
2729
get :public_timeline do
2830
Tweet.limit(20)
2931
end
3032
3133
get :home_timeline do
34+
authenticate!
3235
current_user.home_timeline
3336
end
3437
38+
get '/show/:id' do
39+
Tweet.find(params[:id])
40+
end
41+
3542
post :update do
43+
authenticate!
3644
Tweet.create(
45+
:user => current_user,
3746
:text => params[:status]
3847
)
3948
end
4049
end
4150
end
4251

43-
# Rack endpoint
44-
Twitter::API.statuses.timelines.get(:public_timeline)
52+
This would create a Rack application that could be used like so (in a Rackup file):
53+
54+
use Twitter::API
4555

46-
class Twitter::API::User < Grape::Resource::ActiveRecord
47-
represents ::User
48-
49-
property :status, lambda{|u| u.latest_status}, Twitter::API::Status
50-
end
56+
And would respond to the following routes:
57+
58+
GET /1/statuses/public_timeline(.json)
59+
GET /1/statuses/home_timeline(.json)
60+
GET /1/statuses/show/:id(.json)
61+
POST /1/statuses/update(.json)
62+
63+
Serialization takes place automatically. For more detailed usage information, please visit the [Grape Wiki](http://github.com/intridea/grape/wiki).
5164

52-
== Note on Patches/Pull Requests
65+
## Note on Patches/Pull Requests
5366

5467
* Fork the project.
5568
* Make your feature addition or bug fix.
5669
* Add tests for it. This is important so I don't break it in a future version unintentionally.
5770
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
5871
* Send me a pull request. Bonus points for topic branches.
5972

60-
== Copyright
73+
## Copyright
6174

6275
Copyright (c) 2010 Michael Bleigh and Intridea, Inc. See LICENSE for details.

README.rdoc

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)