Skip to content

Commit cd40509

Browse files
committed
init
0 parents  commit cd40509

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

.gitignore

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Compiled Object files, Static and Dynamic libs (Shared Objects)
2+
*.o
3+
*.a
4+
*.so
5+
6+
# Folders
7+
_obj
8+
_test
9+
10+
# Architecture specific extensions/prefixes
11+
*.[568vq]
12+
[568vq].out
13+
14+
*.cgo1.go
15+
*.cgo2.c
16+
_cgo_defun.c
17+
_cgo_gotypes.go
18+
_cgo_export.*
19+
20+
_testmain.go
21+
22+
*.exe
23+
*.test
24+
*.prof
25+
coverage.txt
26+
profile.out
27+
cpu.out
28+
mem.out
29+
30+
tls-gramecache.dev
31+
tls-gramecache
32+
33+
infraclient
34+
intercom
35+
users
36+
db
37+
38+
test_cert.pem
39+
test_key.pem
40+
41+
disabled
42+
nettls_*
43+
.idea
44+
45+
3s

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Simple SPA Server (3s)
2+
3+
Oficcial Gramework's simple SPA server

main.go

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package main
2+
3+
import (
4+
"strings"
5+
6+
"github.com/gramework/gramework"
7+
"github.com/spf13/pflag"
8+
)
9+
10+
var (
11+
indexPath = pflag.StringP("indexpath", "i", "./index.html", "index file path")
12+
staticPath = pflag.StringP("staticpath", "s", "./", "static directory path")
13+
staticRoute = pflag.StringP("staticroute", "r", "/static", "static route")
14+
bind = pflag.StringP("bind", "b", ":80", "port to listen")
15+
cache = pflag.BoolP("cache", "c", false, "enable cache")
16+
)
17+
18+
func main() {
19+
pflag.Parse()
20+
21+
gramework.DisableFlags()
22+
app := gramework.New()
23+
24+
app.SPAIndex(*indexPath)
25+
26+
slashCnt := strings.Count(*staticRoute, "/")
27+
h := app.ServeDirNoCacheCustom(*staticPath, slashCnt, true, false, nil)
28+
if *cache {
29+
h = app.ServeDirCustom(*staticPath, slashCnt, true, false, nil)
30+
}
31+
app.GET(*staticRoute+"/*any", h)
32+
33+
app.ListenAndServe(*bind)
34+
}

0 commit comments

Comments
 (0)