Arcanum
THIS PROJECT IS STILL IN DEVELOPMENT SO IT ISN'T DONE YET AND THINGS WILL CHANGE
This is a side project i've started to create a simple framework for myself.
TODO list:
- Basic functionality (Routing, files)
- Templating
- Models (DB)
- docs
How to use
to use this library add
[]
= "0.1"
= { = "1.0", = ["derive"] }
to the cargo.toml file.
to instantiate and run the basic web server is:
let mut server = new;
server.run;
where the "127.0.0.1" is the address and 7878 is the port of the server.
to add a simple route use
server.add_simple_route;
Where handle_main_route
is a function defined in the main.rs file
to define everything needed for handle_main_route like
the HomepageContext gets used by Template to see what to insert into the template, you could add 90 other variables to it if it would be deemed necessary.
the views/index.html
content is like so
Home page
{ title }, Title from rust content Object
to add a route with params like an id or something similar we would use
server.add_route_with_params;
in this case the /id route would still match this and no param would get passed (still working on that)
in this case the handle_id_route is handled like so:
Once again we are using templates
Document
{ id } This should be the id given by the path in the browser
this is the template for id.
Helper functions
serve_static_file
serves a static file based on the path you provide this cannot be used to provide as a function in add_simple_route, so you have to wrap it. see examples/basic/main.rs
for more info.