Adding Tera for templates
This commit is contained in:
parent
39d12d7765
commit
5e2975ab3b
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rocket = { git = "https://github.com/SergioBenitez/Rocket.git", branch="master" }
|
rocket = { git = "https://github.com/SergioBenitez/Rocket.git", branch="master" }
|
||||||
rocket_contrib = { git = "https://github.com/SergioBenitez/Rocket.git", branch="master" }
|
rocket_contrib = { git = "https://github.com/SergioBenitez/Rocket.git", branch="master", features = ["tera_templates"] }
|
||||||
futures = "0.1.21"
|
futures = "0.1.21"
|
||||||
ldap3 = "0.6"
|
ldap3 = "0.6"
|
||||||
tokio = "0.1.0"
|
tokio = "0.1.0"
|
||||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -28,6 +28,7 @@ use openssl::rsa::Rsa;
|
||||||
use ldap3::{ LdapConn, Scope, SearchEntry };
|
use ldap3::{ LdapConn, Scope, SearchEntry };
|
||||||
use rocket::request::Form;
|
use rocket::request::Form;
|
||||||
use rocket_contrib::json::Json;
|
use rocket_contrib::json::Json;
|
||||||
|
use rocket_contrib::templates::Template;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct BasicAuthentication {
|
struct BasicAuthentication {
|
||||||
|
@ -174,8 +175,11 @@ fn oidc_config() -> Json<OidcConfig> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
fn hello() -> &'static str {
|
fn hello() -> Template {
|
||||||
"Hello!"
|
let config = OidcConfig {
|
||||||
|
jwks_uri: "https://auth.xeen.dev/oauth2/keys".to_string(),
|
||||||
|
};
|
||||||
|
Template::render("hello", &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn routes() -> Vec<rocket::Route> {
|
fn routes() -> Vec<rocket::Route> {
|
||||||
|
@ -190,5 +194,8 @@ fn routes() -> Vec<rocket::Route> {
|
||||||
fn main() {
|
fn main() {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
||||||
rocket::ignite().mount("/", routes()).launch();
|
rocket::ignite()
|
||||||
|
.attach(Template::fairing())
|
||||||
|
.mount("/", routes())
|
||||||
|
.launch();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Auth</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{% block content %}
|
||||||
|
<h1>Hi!</h1>
|
||||||
|
{% endblock content %}
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,5 @@
|
||||||
|
{% extends "base" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Hello!</h1>
|
||||||
|
{% endblock content %}
|
Loading…
Reference in New Issue