-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroute_data.go
41 lines (38 loc) · 995 Bytes
/
route_data.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"fmt"
"time"
"html/template"
"net/http"
"github.com/dgrijalva/jwt-go"
. "github.com/logrusorgru/aurora"
)
func Data(w http.ResponseWriter, r *http.Request) {
fmt.Println(Gray(8-1, "Starting Data..."))
claims := &jwt.MapClaims{
"exp": time.Now().Add(time.Hour).Unix(),
"params": map[string]string{},
"resource": map[string]int{
"dashboard": 1,
},
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
secretKey := "b8077945abd4d7bf06f4dcf3544dbb0a91fda42502a412ee627e2edb18a58d44"
tokenString, err := token.SignedString([]byte(secretKey))
if err != nil {
panic(err.Error())
}
iframeUrl := "https://metabase.jeifai.com/embed/dashboard/" + tokenString
infos := struct {
Metabase string
}{
iframeUrl,
}
templates := template.Must(
template.ParseFiles(
"templates/OUT_navbar.html",
"templates/OUT_head.html",
"templates/OUT_data.html",
"templates/OUT_footer.html",))
templates.ExecuteTemplate(w, "layout", infos)
}