init
This commit is contained in:
commit
793560c0c4
7 changed files with 97 additions and 0 deletions
15
auth_middleware.rb
Normal file
15
auth_middleware.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
class AuthMiddleware
|
||||
def initialize(app)
|
||||
@app = app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
auth = env['HTTP_AUTHORIZATION']
|
||||
if auth == "Bearer mysecrettoken"
|
||||
@app.call(env)
|
||||
else
|
||||
[401, { "Content-Type" => "application/json" }, [{ error: "Unauthorized" }.to_json]]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue