Fetch gitlab token from env vars
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
parent
b7ee0a0c7c
commit
3d3e3512db
1 changed files with 3 additions and 1 deletions
|
@ -2,6 +2,7 @@ use actix_web::{get, App, HttpResponse, HttpServer, Responder, web::{Data, Query
|
||||||
use tera::{Tera, Context};
|
use tera::{Tera, Context};
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
use reqwest::{Client, header::HeaderMap};
|
use reqwest::{Client, header::HeaderMap};
|
||||||
|
use std::env;
|
||||||
|
|
||||||
struct Template {
|
struct Template {
|
||||||
paste: Tera,
|
paste: Tera,
|
||||||
|
@ -31,9 +32,10 @@ struct ResponseJSON {
|
||||||
async fn paste_render(data: Data<Template>, paste: Query<Paste>) -> impl Responder {
|
async fn paste_render(data: Data<Template>, paste: Query<Paste>) -> impl Responder {
|
||||||
let my_data = data.get_ref();
|
let my_data = data.get_ref();
|
||||||
let mut context = Context::new();
|
let mut context = Context::new();
|
||||||
|
let gitlab_token = env::var("GITLAB_TOKEN").unwrap_or("".to_string());
|
||||||
let client = Client::new();
|
let client = Client::new();
|
||||||
let mut headers = HeaderMap::new();
|
let mut headers = HeaderMap::new();
|
||||||
headers.insert("PRIVATE-TOKEN", "".parse().unwrap());
|
headers.insert("PRIVATE-TOKEN", gitlab_token.parse().unwrap());
|
||||||
let paste_content: String;
|
let paste_content: String;
|
||||||
if paste.paste_id.is_some() {
|
if paste.paste_id.is_some() {
|
||||||
let response = client.get(format!("https://git.baalajimaestro.me/api/v4/projects/12/repository/files/paste%2F{}.md?ref=master", paste.paste_id.as_ref().unwrap())).headers(headers).send().await.unwrap();
|
let response = client.get(format!("https://git.baalajimaestro.me/api/v4/projects/12/repository/files/paste%2F{}.md?ref=master", paste.paste_id.as_ref().unwrap())).headers(headers).send().await.unwrap();
|
||||||
|
|
Loading…
Reference in a new issue