Skip to content

Commit 0f62afb

Browse files
committed
add titan example
1 parent 12af500 commit 0f62afb

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

examples/titan/file.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▄▄ ▄▄▄ ▄▄
2+
▀▀▀██▀▀▀ ▀▀██▀▀ ▀▀▀██▀▀▀ ████ ███ ██
3+
██ ██ ██ ████ ██▀█ ██
4+
██ ██ ██ ██ ██ ██ ██ ██
5+
██ ██ ██ ██████ ██ █▄██
6+
██ ▄▄██▄▄ ██ ▄██ ██▄ ██ ███
7+
▀▀ ▀▀▀▀▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀▀

examples/titan/main.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package main
2+
3+
import (
4+
"os"
5+
6+
"github.com/pitr/gig"
7+
)
8+
9+
func main() {
10+
g := gig.Default()
11+
g.AllowProxying = true
12+
g.Use(gig.Titan(1024))
13+
14+
g.Handle("/file.txt*", func(c gig.Context) error {
15+
if c.Get("titan").(bool) {
16+
data, err := gig.TitanReadFull(c)
17+
if err != nil {
18+
return err
19+
}
20+
21+
err = os.WriteFile("file.txt", data, 0644)
22+
if err != nil {
23+
return err
24+
}
25+
gig.TitanRedirect(c)
26+
return nil
27+
}
28+
return c.File("file.txt")
29+
})
30+
31+
g.Run("../astro.crt", "../astro.key")
32+
}

0 commit comments

Comments
 (0)