Sha256: d53cc3b0e8fdeb11393a8c6829aa50a4d9309c04b8f00412f13b1818f78b5205
Contents?: true
Size: 849 Bytes
Versions: 1
Compression:
Stored size: 849 Bytes
Contents
require 'micropub' module Micropub::Server::Rails class Middleware def initialize(app) @app = app end def call(env) if env["PATH_INFO"] == "/micropub" token = Micropub::Token.new(auth_token(env)) token.valid? ? response : error_response else @app.call env end end def auth_token(env) input = env["HTTP_AUTHORIZATION"] || request(env).params["access_token"] || "" input.split("Bearer ").last end def response [201, headers, body] end def error_response [401, {}, body] end def body [""] end def request(env) Rack::Request.new(env) end def headers { "Location" => "http://bookisworthy.com/posts/1", "Content-Type" => "text/plain; charset=utf-8" } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
micropub-server-rails-0.1.5 | lib/micropub/server/rails/middleware.rb |