mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-04-18 12:45:52 +00:00
remove pointless authentication, fix up status & headers
This commit is contained in:
parent
034d975225
commit
7e47c2d670
1 changed files with 7 additions and 20 deletions
|
|
@ -76,47 +76,34 @@ end
|
|||
|
||||
# list years
|
||||
get '/years' do
|
||||
unless authenticated?(request['Auth'])
|
||||
status 403
|
||||
return 'forbidden'
|
||||
end
|
||||
|
||||
status 200
|
||||
headers 'Content-Type' => 'application/json'
|
||||
JSON.generate(years: blog.years)
|
||||
end
|
||||
|
||||
# list months
|
||||
get '/months' do
|
||||
unless authenticated?(request['Auth'])
|
||||
status 403
|
||||
return 'forbidden'
|
||||
end
|
||||
|
||||
status 200
|
||||
headers 'Content-Type' => 'application/json'
|
||||
JSON.generate(months: blog.months)
|
||||
end
|
||||
|
||||
# list posts
|
||||
get '/posts/:year/?:month?' do |year, month|
|
||||
unless authenticated?(request['Auth'])
|
||||
status 403
|
||||
return 'forbidden'
|
||||
end
|
||||
|
||||
posts =
|
||||
if month
|
||||
blog.posts_for_month(year, month)
|
||||
else
|
||||
blog.posts_for_year(year)
|
||||
end
|
||||
|
||||
status 200
|
||||
headers 'Content-Type' => 'application/json'
|
||||
JSON.generate(posts: posts.map(&:fields))
|
||||
end
|
||||
|
||||
# get a post
|
||||
get '/posts/:year/:month/:slug' do |year, month, slug|
|
||||
unless authenticated?(request['Auth'])
|
||||
status 403
|
||||
return 'forbidden'
|
||||
end
|
||||
|
||||
begin
|
||||
post = blog.get_post(year, month, slug)
|
||||
rescue HarpBlog::InvalidDataError => e
|
||||
|
|
|
|||
Loading…
Reference in a new issue