Skip to content

Commit

Permalink
Merge pull request #37 from mamantoha/develop
Browse files Browse the repository at this point in the history
change project structure
  • Loading branch information
mamantoha committed Jul 26, 2024
2 parents 222e6b1 + 58156fe commit fdc9cd2
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog

* **(breaking-change)** Rename `HTTP::Proxy::Server::BasicAuth` to `HTTP::Proxy::Server::BasicAuthHandler` ([#37](https://github.com/mamantoha/http_proxy/pull/37))

## 0.11.0

* Make `HTTP::Proxy::Server` independent ([#35](https://github.com/mamantoha/http_proxy/pull/35))
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ server.listen
```crystal
server = HTTP::Proxy::Server.new(handlers: [
HTTP::LogHandler.new,
HTTP::Proxy::Server::BasicAuth.new("user", "passwd"),
HTTP::Proxy::Server::BasicAuthHandler.new("user", "passwd"),
]) do |context|
context.request.headers.add("X-Forwarded-For", "127.0.0.1")
context.perform
Expand Down
2 changes: 1 addition & 1 deletion samples/server_with_authentication.cr
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ end

server = HTTP::Proxy::Server.new(handlers: [
HTTP::LogHandler.new,
HTTP::Proxy::Server::BasicAuth.new(username, password),
HTTP::Proxy::Server::BasicAuthHandler.new(username, password),
]) do |context|
context.request.headers.add("X-Forwarded-For", host)
context.perform
Expand Down
2 changes: 1 addition & 1 deletion samples/with_proxy_server.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def with_proxy_server(host = "127.0.0.1", port = 8080, username = "user", passwo

server = HTTP::Proxy::Server.new(handlers: [
HTTP::LogHandler.new,
HTTP::Proxy::Server::BasicAuth.new(username, password),
HTTP::Proxy::Server::BasicAuthHandler.new(username, password),
]) do |context|
context.request.headers.add("X-Forwarded-For", host)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/server_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ describe HTTP::Proxy::Server do
server.should be_a(HTTP::Proxy::Server)
end

it "with BasicAuth handler" do
it "with BasicAuthHandler handler" do
server = HTTP::Proxy::Server.new([
HTTP::Proxy::Server::BasicAuth.new("user", "passwd"),
HTTP::Proxy::Server::BasicAuthHandler.new("user", "passwd"),
])
server.should be_a(HTTP::Proxy::Server)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def with_proxy_server(host = "127.0.0.1", port = 8080, username : String? = nil,

server =
if username && password
HTTP::Proxy::Server.new(handlers: [HTTP::Proxy::Server::BasicAuth.new(username, password)])
HTTP::Proxy::Server.new(handlers: [HTTP::Proxy::Server::BasicAuthHandler.new(username, password)])
else
HTTP::Proxy::Server.new
end
Expand Down
6 changes: 5 additions & 1 deletion src/http/proxy/server.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
require "socket"
require "./server/handler"
require "./server/basic_auth"
require "./server/context"
{% if !flag?(:without_openssl) %}
require "openssl"
{% end %}

# A concurrent Proxy server implementation.
#
Expand Down
2 changes: 2 additions & 0 deletions src/http/proxy/server/handler.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ class HTTP::Proxy::Server::Handler

alias HandlerProc = HTTP::Proxy::Server::Context ->
end

require "./handlers/*"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class HTTP::Proxy::Server
class BasicAuth
class BasicAuthHandler
include HTTP::Handler

def initialize(@username : String, @password : String)
Expand Down
1 change: 0 additions & 1 deletion src/http_proxy.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require "http"
require "socket"
require "base64"

require "./http/proxy/server"
Expand Down

0 comments on commit fdc9cd2

Please sign in to comment.