mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 07:16:40 +00:00
rename to rswag plus major refactor - almost a rewrite
This commit is contained in:
7
test-app/app/controllers/application_controller.rb
Normal file
7
test-app/app/controllers/application_controller.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
# Prevent CSRF attacks by raising an exception.
|
||||
# For APIs, you may want to use :null_session instead.
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
wrap_parameters format: [ :json ]
|
||||
end
|
||||
23
test-app/app/controllers/blogs_controller.rb
Normal file
23
test-app/app/controllers/blogs_controller.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
class BlogsController < ApplicationController
|
||||
wrap_parameters Blog
|
||||
respond_to :json
|
||||
|
||||
# POST /blogs
|
||||
def create
|
||||
@blog = Blog.create(params.require(:blog).permit(:title, :content))
|
||||
respond_with @blog
|
||||
end
|
||||
|
||||
# GET /blogs
|
||||
def index
|
||||
@blogs = Blog.all
|
||||
respond_with @blogs
|
||||
end
|
||||
|
||||
# GET /blogs/1
|
||||
def show
|
||||
@blog = Blog.find_by_id(params[:id])
|
||||
respond_with @blog, status: :not_found and return unless @blog
|
||||
respond_with @blog
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user