Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change project structure #37

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading