Skip to content

Commit

Permalink
Added --no-tunnel support. Preparing for release.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdlaird committed Nov 21, 2024
1 parent 7c81656 commit 8db5501
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Added

- `default_route` and `default_route_methods` can be regex patterns, allowing for more flexible route matching.
- `--default-route` can be regex pattern, allowing for more flexible route matching.
- `ngrok` tunnel can now be disabled by passing `--no-tunnel` to CLI.

### Fixed

- CLI arg `--host_header` is now `--host-header`, matching other args.

## [2.3.6](https://github.com/alexdlaird/hookee/compare/2.3.5...2.3.6) - 2024-11-20

### Added

- Let the default route (`/webhook`) be set in the config or passed via the CLI with `default_route`.
- Let the default route (`/webhook`) be set in the config with `default_route` or passed via the CLI with `--default-route`.

## [2.3.5](https://github.com/alexdlaird/hookee/compare/2.3.4...2.3.5) - 2024-04-09

Expand Down
5 changes: 3 additions & 2 deletions hookee/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
@click.group(invoke_without_command=True)
@click.pass_context
@click.option("--port", type=int, help="The local port for the webserver and ngrok tunnel.")
@click.option('--default_route', type=str, help="The URI regex to map to the default webhook.")
@click.option('--default-route', type=str, help="The URI regex to map to the default webhook.")
@click.option('--no-tunnel', is_flag=True, default=False, help="Do not open an ngrok tunnel.")
@click.option("--subdomain", help="The subdomain to use for ngrok endpoints.")
@click.option("--region", type=click.Choice(["us", "eu", "ap", "au", "sa", "jp", "in"]),
help="The region to use for ngrok endpoints.")
@click.option("--hostname", help="The hostname to use for ngrok endpoints.")
@click.option("--auth", help="The basic auth to use for ngrok endpoints.")
@click.option("--host_header", help="The \"Host\" header value to use for ngrok endpoints.")
@click.option("--host-header", help="The \"Host\" header value to use for ngrok endpoints.")
@click.option("--response", type=str,
help="Data to set for the response, overriding all body data from plugins and `--response-script`.")
@click.option("--content-type", type=str,
Expand Down
1 change: 1 addition & 0 deletions hookee/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"default_route": confuse.String(default="/webhook$"),
"default_route_methods": confuse.String(default="^(GET|HEAD|POST|PUT|DELETE|PATCH|OPTIONS|TRACE|CONNECT)$"),
"port": int,
"no_tunnel": confuse.OneOf([True, False], default=False),
"subdomain": confuse.String(default=None),
"region": confuse.Choice(["us", "eu", "ap", "au", "sa", "jp", "in", "us-cal-1"], default=None),
"domain": confuse.String(default=None),
Expand Down
12 changes: 9 additions & 3 deletions hookee/hookeemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,20 @@ def print_ready(self):

self.print_util.print_open_header("Registered Endpoints")

if self.tunnel.public_url:
host = self.tunnel.public_url
else:
host = f"http://localhost:{self.server.port}"

default_route = self.config.get("default_route")
default_route_methods = self.config.get("default_route_methods").split(",")
self.print_util.print_basic(f" * {self.tunnel.public_url}{default_route}", print_when_logging=True)
self.print_util.print_basic(f" * {host}{default_route}", print_when_logging=True)
self.print_util.print_basic(f" Methods: {sorted(list(default_route_methods))}", print_when_logging=True)

rules = list(filter(lambda r: r.rule not in ["/<path:uri>", "/shutdown", "/status", "/static/<path:filename>"],
self.server.app.url_map.iter_rules()))
for rule in rules:
self.print_util.print_basic(f" * {self.tunnel.public_url}{rule.rule}", print_when_logging=True)
self.print_util.print_basic(f" * {host}{rule.rule}", print_when_logging=True)
self.print_util.print_basic(f" Methods: {sorted(list(rule.methods))}", print_when_logging=True)

self.print_util.print_close_header()
Expand Down Expand Up @@ -178,6 +183,7 @@ def fail(self, msg, e=None):
def _init_server_and_tunnel(self):
self.alive = True
self.server.start()
self.tunnel.start()
if not self.config.get("no_tunnel"):
self.tunnel.start()

self.print_ready()

0 comments on commit 8db5501

Please sign in to comment.