LiveReloadProxyServer class
A livereload proxy server.
This server proxies requests to build_runner serve
and injects a script that will reload the browser on reloadSignal. (See injectJavaScript and reloadOn.)
If this serves a single page application, it will rewrite any 404 response whose path doesn't have a MIME type to the root path of build_runner serve
. (See rewriteTo and shouldBeRewritten.)
If this heuristic doesn't work well for you, please file an issue. Furthermore, PRs are welcome.
Call serve to start the server at uri. A pipeline can be added to customize the behavior of the server.
This should be used together with LiveReloadWebSocketServer.
This needs some understanding of package: shelf
.
- Inheritance
- Object
- ProxyServer
- LiveReloadProxyServer
Constructors
- LiveReloadProxyServer(Uri uri, Uri buildRunnerUri, Uri webSocketUri, Future<Null> buildRunnerServed, bool isSinglePageApplication, [ Pipeline pipeline = const Pipeline() ])
- LiveReloadProxyServer.fromParsed(ArgResults results, BuildRunnerServeProcess buildRunner, LiveReloadWebSocketServer webSocketServer, [ Pipeline pipeline = const Pipeline() ])
-
Set up a LiveReloadProxyServer with arguments parsed by liveReloadArgParser.
factory
Properties
- buildRunnerServed → Future<Null>
-
A future which will resolve when
build_runner
starts serving. [...]final - buildRunnerUri → Uri
-
final
- webSocketUri → Uri
-
final
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- pipeline → Pipeline
-
final, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
- to → Uri
-
final, inherited
- uri → Uri
-
final, inherited
Methods
-
serve(
[logMessage = _defaultMessage ]) → Future<Null> -
Starts this server at uri and will log a message returned from
logMessage
when this server is successfully started. [...] -
forceClose(
) → Future -
Forces the server to close.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
other) → bool -
The equality operator. [...]
inherited
Static Methods
-
shouldBeRewritten(
Request request, Response response) → bool -
Returns
true
for any 404 response whose path doesn't have a MIME type.