用 Ruby 开发 Blog API,基于 Rails 和 Grape 搭建
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
bin
config
db
lib
log
public
spec
vendor/assets
.coveralls.yml
.gitignore
.travis.yml
Gemfile
Gemfile.lock
README.md
Rakefile
config.ru
setup.rb

README.md

BlogApi

Build Status Code Climate Coverage Status

用Ruby构建Blog Api之Grape

How to Install

git clone git@github.com:agilejzl/BlogApi.git
cd BlogApi
ruby setup.rb
# 请确保mysql已经启动
rails s

接口访问示例

查询所有:

curl -X GET 'http://blog-api.herokuapp.com/v1/articles' | json_pp

查询单个:

curl -X GET 'http://blog-api.herokuapp.com/v1/articles/1'

创建单个:

curl -X POST -d '{"author_name": "zs","article":{"title": "haha", "content": "88 characters"}}' 'http://blog-api.herokuapp.com/v1/articles' -H Content-Type:application/json

更新单个:

curl -X PUT -d '{"author_name": "ww","article":{"title": "haha2", "content": "no more"}}' 'http://blog-api.herokuapp.com/v1/articles/1' -H Content-Type:application/json

删除单个:

curl -X DELETE 'http://blog-api.herokuapp.com/v1/articles/1'

How to Test

Models and API tests:

rspec spec/models && rspec spec/app