Beispiel #1
0
//Oppretter REST ressurs for applikasjon
func opprettIsolatRessurs(appConfig core.AppConfig) *web.WebRouter {
	r := web.NewRoute()

	r.Path(appConfig.Server.Root)
	r.Method(web.HttpGet).Method(web.HttpPost)
	r.Handler(core.NyRestHandler())

	router := web.NewWebRouter()
	router.AddRoute(r)
	return router
}
Beispiel #2
0
//The application is simple blog webapplication with html and a REST interface.
//It is created with a custom middleware for handing httprequests,
//routing requests to handlers serving html or json content from a database.
func main() {
	//Enables profiler...
	go func() {
		http.ListenAndServe("localhost:6060", nil)
	}()

	//Testing the databasesetup.
	initDb()
	router := web.NewWebRouter()

	//The static route handles static html files.
	router.AddRoute(createChainedHtmlRoute())

	//Adds basic html CRUD support for articles
	router.AddRoute(createNewArticleHtmlRoute())
	router.AddRoute(createListArticleHtmlRoute())
	router.AddRoute(createFindArticleHtmlRoute())

	//Adds REST support for CRUD operations on articles.
	router.AddRoute(createJsonRoute())

	http.ListenAndServe(":8888", router)
}