Пример #1
0
func Example_Specific() {
	rackup := rack.New()
	rackup.Add(templater.GetTemplates("test_templates"))
	rackup.Add(encapsulator.AddLayout)
	rackup.Add(SetErrorLayout)

	conn := httper.HttpConnection(":3001")
	go conn.Go(rackup)

	GetFrom("http://localhost:3001/")

	//output: Not Found
}
Пример #2
0
func Example_SpecificOverride() {
	rackup := rack.New()
	rackup.Add(templater.GetTemplates("test_templates"))
	rackup.Add(encapsulator.AddLayout)
	rackup.Add(SetErrorLayout)
	rackup.Add(ErrorWare2)

	conn := httper.HttpConnection(":3002")
	go conn.Go(rackup)

	GetFrom("http://localhost:3002/")

	//output: Not Implemented!
}
Пример #3
0
func Example_General() {
	rackup := rack.New()
	rackup.Add(templater.GetTemplates("test_templates"))
	rackup.Add(encapsulator.AddLayout)
	rackup.Add(SetErrorLayout)
	rackup.Add(ErrorWare)

	conn := httper.HttpConnection(":4014")
	go conn.Go(rackup)

	GetFrom("http://localhost:4014/")

	//output: Error - 500
}
func Example_NoLayout() {
	rackup := rack.New()
	rackup.Add(templater.GetTemplates("./test_templates"))
	rackup.Add(AddLayout)
	rackup.Add(rack.Func(func(vars map[string]interface{}, next func()) {
		vars["Title"] = "Hello World"
		(httper.V)(vars).AppendMessageString("Hello World!")
	}))

	conn := httper.HttpConnection(":3001")
	go conn.Go(rackup)

	GetFrom("http://localhost:3001/")
	//output: Hello World!
}
Пример #5
0
func Example_Render() {
	rackup := rack.New()
	rackup.Add(logger.New(os.Stdout, "", 0))
	rackup.Add(templater.GetTemplates("./test_templates"))
	rackup.Add(rack.Func(func(vars map[string]interface{}, next func()) {
		vars["Object"] = "World"
		next()
	}))
	rackup.Add(Renderer{"test"})

	conn := httper.HttpConnection(":4010")
	go conn.Go(rackup)

	GetFrom("http://localhost:4010/")
	//output: Hello World
}
func Example_Basic() {
	rackup := rack.New()
	rackup.Add(templater.GetTemplates("./test_templates"))
	rackup.Add(AddLayout)
	rackup.Add(rack.Func(func(vars map[string]interface{}, next func()) {
		vars["Layout"] = "test"
		vars["Title"] = "Hello World"
		(httper.V)(vars).AppendMessageString("Hello World!")
	}))

	conn := httper.HttpConnection(":4000")
	go conn.Go(rackup)

	GetFrom("http://localhost:4000/")
	//output: <html><head><title>Hello World</title></head><body>Hello World!</body></html>
}
Пример #7
0
func init() {
	jar, err := cookiejar.New(nil)
	if err != nil {
		panic("No Cookie Jar!")
	}
	client = &http.Client{Jar: jar}
	root := NewRoot(redirecter.Redirecter{"http://localhost:5001/coins"})
	coinRoute := NewResource(&Coins{})
	root.AddRoute(coinRoute)

	rackup := rack.New()
	rackup.Add(templater.GetTemplates("./test_templates"))
	rackup.Add(sessioner.Middleware)
	rackup.Add(root)

	conn := httper.HttpConnection(":5001")
	go conn.Go(rackup)
}