Closed vi closed 4 years ago
I'm not super keen on allowing a trailing and
because in many cases that is more likely to signal a usage error than anything else.
Can you give an example of a way you'd like to use weave that would benefit from a trailing and
? In the above example it would be easy to avoid it; do you plan on doing some more complex programmatic usage?
In the above example it would be easy to avoid it
How would it be avoided without making any line (first or last) special and without additional code?
Another idea is a dummy forward, so that the code can be like this:
OPTS=dummy
OPTS="and $OPTS =8080/q to http://127.0.0.1:1234/"
OPTS="and $OPTS =8080/w to http://127.0.0.1:1235/"
OPTS="and $OPTS =8080/e to http://127.0.0.1:1236/"
weave $OPTS
This would also allow easy popularion of routes from scripts.
One more idea: OPTS="=8080 to dummy"
to allow starting Weave with effectively zero routes - it should still listen to the port, but simply return 404 for all requests.
How would it be avoided without making any line (first or last) special and without additional code?
I'm not super keen on allowing a trailing or leading 'and' as I think it would often be a sign of user error in typical weave usage.
The idea of a dummy/noop/sink route is interesting though and, as you say, would provide a workaround.
Do you have any concrete reasons for binding to a port and returning a status code? I would be tempted to allow you to forward to something like status://404
so that you can return whatever status code you like. This aligns with how I would handle other types of resources like WebSockets (I should probably allow file://
as well)
Yes, returning arbitrary status codes also fits the bill.
The main idea is forming list of routes programmatically, from multiple optional sources. Example:
ROUTES="8080 to status://404"
if [ "$FOO" = "yes" ]; then
ROUTES="$ROUTES and =8080/foo to http://foo/"
fi
if [ "$BAR" = "yes" ]; then
ROUTES="$ROUTES and =8080/bar to http://bar/"
fi
weave $ROUTES
Startup error should be avoided even in no/no case.
I've implemented a version of this (support for "nothing" in place of a route, and support for "statuscode://204" style syntax as the destination route (or "nothing" there as an alias for "statuscode://404"). in the latest release (v0.5.1), so I'll close this. Let me know what you think! :)
only valid HTTP status codes are allowed
Why so? I'd expect it to support any 2xx
, 4xx
and 5xx
status codes, including custom non-standard. Weave looks like a proper tool for prototyping that.
By the way, does it support 3xx
status codes with a Location:
header? It can be done low-levelish with an pseudo-URL like statuscode://302?location=http%3a%2d%2fexample.com%2f
, maybe with a user-friendly alias like redirect:http://example.com/
Valid as in, a status code that exists rather than one that signals "ok" (2xx) :)
Weave doesn't support headers; redirects are currently passed back to the browser but I have pondered allowing weave to handle them!
Redirects are currently passed back to the browser but I have pondered allowing weave to handle them!
I mean emitting new redirects to location specified on command line.
Maybe a separate Github issues shall be for redirect handling.
Yep, feel free to create a new issue :)
Shall Weave support leading or trailing
and
in command line?:Or can
and
be made completely optional?