Esempio n. 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)
}
Esempio n. 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)
}
Esempio n. 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")
}
Esempio n. 4
0
func getAdminPageRouter() Router {
	var r = ARouter()

	if conf.ADMIN_USER != "" {
		r.Use(auth.ABasicAuth(conf.ADMIN_USER, conf.ADMIN_PASSWORD, ":[intranet]/admin"))
	} else {
		Secretary.Warn("intranet::getAdminPageRouter()", "Administrator authentication is canceled. Please ensure the inner service is "+
			"running on a safe network, otherwise set inner_service_admin_user in cofiguration.")
	}
	var p, err = GetABSPath("./public/intranet")
	if err != nil {
		Secretary.Error("intranet::getAdminPageRouter()", "Fail to locate public directory. Intranet service stops.")
		return nil
	}
	r.Use("/", staticfs.AStaticfs(p))
	r.Get("/tasks", getMergingTaskInfo)
	r.Get("/logs", getLoggingInfo)
	r.Get("/fdinfo", getFDInfo)
	r.Get("/gossiper", getGossipInfo)
	r.Get("/cluster", getClusterInfo)

	return r
}