Sha256: 02f3cb23fb71cb3fd97c8be72ce53f9bf13f351358f2bd3039184e9fad9e8fe1
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
require 'micropub' Micropub.configure do |c| c.token_endpoint = "https://tokens.indieauth.com/token" c.me = "http://bookisworthy.com" c.allowed_scopes = [:post] end module Micropub::Server::Rails class Middleware def initialize(app) @app = app end def call(env) @env = env if env["PATH_INFO"] == "/micropub" token = Micropub::Token.new(auth_token) if token.valid? response else error_response end else @app.call env end end def env @env end def auth_token @auth_token ||= begin input = env["HTTP_AUTHORIZATION"] || params[:access_token] || "" input.split("Bearer ").last end end def response [201, headers, ["I am micropub."]] end def error_response [401, {}, [""]] end def request @request ||= Rack::Request.new(env) end def params request.params 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.3 | lib/micropub/server/rails/middleware.rb |