-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
535 additions
and
490 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
require 'rest-core/builder' | ||
|
||
module RestCore | ||
Simple = RestCore::Builder.client | ||
Simple = Builder.client | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
|
||
require 'rest-core/middleware' | ||
|
||
class RestCore::AuthBasic | ||
def self.members; [:username, :password]; end | ||
include RestCore::Middleware | ||
module RestCore | ||
class AuthBasic | ||
def self.members; [:username, :password]; end | ||
include Middleware | ||
|
||
def call env, &k | ||
if username(env) | ||
if password(env) | ||
app.call(env.merge(REQUEST_HEADERS => | ||
auth_basic_header(env).merge(env[REQUEST_HEADERS])), &k) | ||
def call env, &k | ||
if username(env) | ||
if password(env) | ||
app.call(env.merge(REQUEST_HEADERS => | ||
auth_basic_header(env).merge(env[REQUEST_HEADERS])), &k) | ||
else | ||
app.call(log(env, "AuthBasic: username provided: #{username(env)},"\ | ||
" but password is missing."), &k) | ||
end | ||
elsif password(env) | ||
app.call(log(env, "AuthBasic: password provided: #{password(env)}," \ | ||
" but username is missing."), &k) | ||
else | ||
app.call(log(env, "AuthBasic: username provided: #{username(env)}," \ | ||
" but password is missing."), &k) | ||
app.call(env, &k) | ||
end | ||
elsif password(env) | ||
app.call(log(env, "AuthBasic: password provided: #{password(env)}," \ | ||
" but username is missing."), &k) | ||
else | ||
app.call(env, &k) | ||
end | ||
end | ||
|
||
def auth_basic_header env | ||
{'Authorization' => | ||
"Basic #{["#{username(env)}:#{password(env)}"].pack('m0')}"} | ||
def auth_basic_header env | ||
{'Authorization' => | ||
"Basic #{["#{username(env)}:#{password(env)}"].pack('m0')}"} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
|
||
module RestCore; end | ||
|
||
# the simplest middleware | ||
class RestCore::Bypass | ||
def initialize app | ||
@app = app | ||
end | ||
module RestCore | ||
class Bypass | ||
def initialize app | ||
@app = app | ||
end | ||
|
||
def call env, &k | ||
@app.call(env, &k) | ||
def call env, &k | ||
@app.call(env, &k) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.