Skip to content

Commit

Permalink
add titan example
Browse files Browse the repository at this point in the history
  • Loading branch information
TeddyDD committed Mar 11, 2022
1 parent 396f431 commit 3853f1c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/titan/file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▄▄ ▄▄▄ ▄▄
▀▀▀██▀▀▀ ▀▀██▀▀ ▀▀▀██▀▀▀ ████ ███ ██
██ ██ ██ ████ ██▀█ ██
██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██████ ██ █▄██
██ ▄▄██▄▄ ██ ▄██ ██▄ ██ ███
▀▀ ▀▀▀▀▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀▀
32 changes: 32 additions & 0 deletions examples/titan/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package main

import (
"os"

"github.com/pitr/gig"
)

func main() {
g := gig.Default()
g.AllowProxying = true
g.Use(gig.Titan(1024))

g.Handle("/file.txt*", func(c gig.Context) error {
if c.Get("titan").(bool) {
data, err := gig.TitanReadFull(c)
if err != nil {
return err
}

err = os.WriteFile("file.txt", data, 0644)
if err != nil {
return err
}
gig.TitanRedirect(c)
return nil
}
return c.File("file.txt")
})

g.Run("../astro.crt", "../astro.key")
}

0 comments on commit 3853f1c

Please sign in to comment.