示例#1
0
文件: main.go 项目: metakeule/pgsql
func main2a() {
	rt := router.New()

	prest := rest.NewREST(DB, registry, rt).Mount(PERSON, "person", rest.READ, nil)
	pget := prest[rest.READ]

	router.MustMount("/api/v1", rt)

	fmt.Println(pget.MustURL("person_id", "9d12b0e6-773f-432a-b31a-a77a87dbd7d1"))

	http.ListenAndServe(":8080", nil)
}
示例#2
0
文件: main.go 项目: metakeule/pgsql
func main() {
	RESTRouter := router.NewETagged()
	REST := rest.NewREST(DB, registry, RESTRouter)

	REST.Mount(
		PERSON, "person",
		rest.CREATE|rest.READ|rest.UPDATE|rest.LIST,
		nil)

	REST.Mount(
		CORPORATION, "corporation",
		rest.CREATE|rest.READ|rest.UPDATE|rest.DELETE|rest.LIST,
		rest.MaxLimit(10).
			SetSortFields(
				CORPORATION.Id,
				CORPORATION.Name,
				CORPORATION.FoundedAt,
			),
	)

	/*
		RESTPerson := rest.NewCRUD(PERSON).Mount(DB, RESTRouter, "person", rest.MaxLimit(10))
		RESTPerson.ReadRoute()
		RESTPerson.ListRoute()
		RESTPerson.UpdateRoute()
		RESTPerson.CreateRoute()

		RESTCorporation := rest.NewCRUD(CORPORATION).Mount(DB, RESTRouter, "corporation",
			rest.MaxLimit(10).SetSortFields(CORPORATION.Id, CORPORATION.Name, CORPORATION.FoundedAt))
		RESTCorporation.ReadRoute()
		RESTCorporation.DeleteRoute()
		RESTCorporation.ListRoute()
		RESTCorporation.UpdateRoute()
		RESTCorporation.CreateRoute()

	*/
	router.MustMount("/api/v1", RESTRouter)

	//rack.New(h, ...)

	http.ListenAndServe(":8080", nil)
}