Update header, and fix raw from fileview.

Signed-off-by: Odyssey <odyssey346@disroot.org>
このコミットが含まれているのは:
Odyssey 2022-11-30 18:32:15 +01:00
コミット 0c6b23cde0
3個のファイルの変更12行の追加1行の削除

10
main.go
ファイルの表示

@ -115,6 +115,7 @@ func main() {
"file": file, "file": file,
"fullname": c.Params("user") + "/" + c.Params("repo"), "fullname": c.Params("user") + "/" + c.Params("repo"),
"name": c.Params("file"), "name": c.Params("file"),
"branch": c.Params("branch"),
}) })
}) })
app.Get("/avatar/:id", func(c *fiber.Ctx) error { app.Get("/avatar/:id", func(c *fiber.Ctx) error {
@ -135,6 +136,15 @@ func main() {
c.Response().Header.Del(fiber.HeaderServer) c.Response().Header.Del(fiber.HeaderServer)
return nil return nil
}) })
app.Get("/raw/:user/:repo/:branch/:file", ratelimiter, func(c *fiber.Ctx) error {
url := "https://raw.githubusercontent.com/" + c.Params("user") + "/" + c.Params("repo") + "/" + c.Params("branch") + "/" + c.Params("file")
if err := proxy.Do(c, url); err != nil {
return err
}
// Remove Server header from response
c.Response().Header.Del(fiber.HeaderServer)
return nil
})
val, ok := os.LookupEnv("GOTHUB_PORT") val, ok := os.LookupEnv("GOTHUB_PORT")
if !ok { if !ok {
val = "3000" val = "3000"

ファイルの表示

@ -192,6 +192,7 @@ a:hover {
color: var(--text); color: var(--text);
padding: 8px; padding: 8px;
border-radius: 8px; border-radius: 8px;
white-space: pre-wrap;
} }

ファイルの表示

@ -11,7 +11,7 @@
<pre class="filePre">{{ .file}}</pre> <pre class="filePre">{{ .file}}</pre>
</div> </div>
<div class="downloadParent"> <div class="downloadParent">
<a href="/raw/{{.fullname}}/{{.name}}" class="downloadButton">Download</a> <a href="/raw/{{.fullname}}/{{.branch}}/{{.name}}" class="downloadButton">Download</a>
</div> </div>
{{end}} {{end}}
</main> </main>