コード例 #1
0
ファイル: main.go プロジェクト: hackerspainters/hp
func main() {
	fmt.Printf("Using config %s\n", conf.Path)
	fmt.Printf("Using models:\n")
	for _, m := range db.Models {
		t := reflect.TypeOf(m)
		fmt.Printf("    %s\n", fmt.Sprintf("%s", t)[1:])
	}

	// Establish session with mongodb
	db.Connect(conf.Config.DbHostString(), conf.Config.DbName)
	db.RegisterAllIndexes()

	m := martini.Classic()

	m.Use(martini.Static("static"))
	m.Use(DB(conf.Config.DbName))

	m.Use(render.Renderer(render.Options{
		Directory: "templates",
		Layout:    "layout", // Specify a layout template
		Charset:   "UTF-8",  // Sets encoding for json and html content-types. Default is "UTF-8".
		//IndentJSON: true, // Output human readable JSON
	}))

	m.NotFound(NotFoundHandler)
	m.Get("/", HomeHandler)
	m.Get("/events", event.EventListHandler)
	m.Get("/events/past", event.EventPastHandler)
	m.Get("/events/next", event.EventNextHandler)
	m.Get("/organise", event.OrganiseHandler)
	m.Get("/event/add", event.EventAddHandler)

	// Facebook related features
	// one-off link that allows event owner to grab group-specific events set with group-only perms
	m.Get("/facebook/login", FacebookLoginHandler)
	m.Get("/channel.html", FacebookChannelHandler)
	m.Get("/events/grab", event.EventGrabHandler)
	m.Post("/events/import", event.EventImportHandler)

	m.Post("/events/register", binding.Bind(event.Attendee{}), event.RegisterEventAttendeeHandler)

	m.Get("/event/:eid", event.ShowEventAttendees)

	m.Run()

}
コード例 #2
0
ファイル: handlers_test.go プロジェクト: hackerspainters/hp
func TestEventNextHandler(t *testing.T) {

	// set up test database

	fmt.Println("testing EventNext")
	db.Connect("127.0.0.1", "test_db")
	db.RegisterAllIndexes()

	// integration test on http requests to EventNextHandler
	m := martini.Classic()
	m.Get("/events/next/", EventNextHandler)

	request, _ := http.NewRequest("GET", "/events/next/", nil)
	response := httptest.NewRecorder()

	m.ServeHTTP(response, request)

}