Пример #1
0
func ASimpleFSServer(basePath string) Router {
	var fs = staticfs.AStaticfs(basePath).(*staticfs.FsMidware)
	var ay = analyzer.ASimpleAnalyzer()
	fs.DefaultRender = renderDirectory

	return ARouter().Use(ay).Use(fs)
}
Пример #2
0
func NewSimpleFSServer(basePath string, cacheStrategy staticfs.CacheStrategy, autoIndexing bool) Router {
	var fs = staticfs.AStaticfs(basePath).(*staticfs.FsMidware)
	if autoIndexing {
		fs.DefaultRender = renderDirectory
	}
	var ay = analyzer.ASimpleAnalyzer()
	fs.CacheControl = cacheStrategy

	return ARouter().Use(ay).Use(fs)
}
Пример #3
0
func main() {
	var router = ARouter()
	var page = getPageRouter()

	router.Use(analyzer.ASimpleAnalyzer())
	router.Use(staticfs.AStaticfs("public/"))
	router.Get(func(res Response) {
		res.Send("This is index.")
	}).Use("/page", page)

	fmt.Println("Running...")
	router.Launch(":8192")
}
Пример #4
0
func main() {
	var router = ARegexpRouter()

	router.Use(analyzer.ASimpleAnalyzer())
	router.Get(`/(\d+)`, func(req Request, res Response) {
		var matchResult = req.F()[matcher.REGEXP_RESULT].([]string)
		res.Send("The digits are " + matchResult[1])
	})
	router.Get(`/.*`, func(req Request, res Response) {
		res.Send("Please visit paths consisting of digits.")
	})

	fmt.Println("Running...")
	router.Launch(":8192")
}