command-line interface

Toolips has a rather robust, but easy to understand command-line interface that is used via the WebServer type. Extensions can be accessed by indexing a WebServer with a Symbol or the extensions(::WebServer) method, and routes can be accessed by doing routes(::WebServer).

using Toolips

st = ServerTemplate()
r = route("/") do c::Connection
  write!(c, "my return")
end
st.add(r)

webserver = st.start()

println(extensions(webserver))

println(routes(webserver))
1-element Dict{Symbol, ServerExtension}
:Logger => Toolips.Logger(...)

1-element Dict{String, Function}
"/" => #5

We can also use the WebServer with the route! function with the following methods:

Toolips.route!Method

Interface

route!(ws::WebServer, r::String, f::Function) -> _


Reroutes a server's route r to function f.

example

ws = MyProject.start()

function myf(c::Connection)
    write!(c, "pasta")
end
route!(ws, "/", myf)
Toolips.route!Method

Interface

route!(f::Function, ws::WebServer, r::String) -> _


Reroutes a server's route r to function f.

example

ws = MyProject.start()
route!(ws, "/") do c
    c[:Logger].log("rerouted!")
end
Toolips.route!Method

Interface

route!(ws::WebServer, r::Route) -> _


Reroutes a server's route r.

example

ws = MyProject.start()
r = route("/") do c

end
route!(ws, r)