當前位置: 首頁>>代碼示例>>Golang>>正文


Golang martini.Router類代碼示例

本文整理匯總了Golang中github.com/go-martini/martini.Router的典型用法代碼示例。如果您正苦於以下問題:Golang Router類的具體用法?Golang Router怎麽用?Golang Router使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Router類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: AddRoutes

func AddRoutes(r martini.Router) {
	r.Group("/api/v1", func(r martini.Router) {
		addNeedRoutes(r)
		addResourceRoutes(r)
		addStaffRoutes(r)
	}, MapCodec)
}
開發者ID:riannucci,項目名稱:fish_basket,代碼行數:7,代碼來源:routes.go

示例2: mapChildNamespaceRoute

// mapChildNamespaceRoute sets a handler returning a dictionary of resources
// supported by a certain API version identified by the given namespace
func mapChildNamespaceRoute(route martini.Router, namespace *schema.Namespace) {
	log.Debug("[Path] %s", namespace.GetFullPrefix())
	route.Get(
		namespace.GetFullPrefix(),
		func(w http.ResponseWriter, r *http.Request, p martini.Params, context martini.Context) {
			resources := []schema.NamespaceResource{}
			for _, s := range schema.GetManager().Schemas() {
				if s.NamespaceID == namespace.ID {
					resources = append(resources, schema.NamespaceResource{
						Links: []schema.Link{
							schema.Link{
								Href: s.GetPluralURL(),
								Rel:  "self",
							},
						},
						Name:       s.Singular,
						Collection: s.Plural,
					})
				}
			}

			routes.ServeJson(w, map[string][]schema.NamespaceResource{"resources": resources})
		},
	)
}
開發者ID:vozhyk-,項目名稱:gohan,代碼行數:27,代碼來源:api.go

示例3: addStaffRoutes

func addStaffRoutes(r martini.Router) {
	r.Group("/staff", func(r martini.Router) {
		r.Get("", func() string {
			return "Staff stuff?"
		})
	}, ensureStaffMember)
}
開發者ID:riannucci,項目名稱:fish_basket,代碼行數:7,代碼來源:staff.go

示例4: Register

func (tr *TaskRouter) Register(r martini.Router) {
	r.Get("", tr.GetAllTasks)
	r.Post("", tr.CreateTask)
	r.Get("/:id", tr.GetTask)
	r.Put("/:id", tr.CreateTask)
	r.Delete("/:id", tr.CancelTask)
}
開發者ID:froz,項目名稱:app-scheduler,代碼行數:7,代碼來源:task.go

示例5: mapTopLevelNamespaceRoute

// mapTopLevelNamespaceRoute maps route listing available subnamespaces (versions)
// for a top-level namespace
func mapTopLevelNamespaceRoute(route martini.Router, namespace *schema.Namespace) {
	log.Debug("[Path] %s/", namespace.GetFullPrefix())
	route.Get(
		namespace.GetFullPrefix()+"/",
		func(w http.ResponseWriter, r *http.Request, p martini.Params, context martini.Context) {
			versions := []schema.Version{}
			for _, childNamespace := range schema.GetManager().Namespaces() {
				if childNamespace.Parent == namespace.ID {
					versions = append(versions, schema.Version{
						Status: "SUPPORTED",
						ID:     childNamespace.Prefix,
						Links: []schema.Link{
							schema.Link{
								Href: childNamespace.GetFullPrefix() + "/",
								Rel:  "self",
							},
						},
					})
				}
			}

			if len(versions) != 0 {
				versions[len(versions)-1].Status = "CURRENT"
			}

			routes.ServeJson(w, map[string][]schema.Version{"versions": versions})
		})
}
開發者ID:vozhyk-,項目名稱:gohan,代碼行數:30,代碼來源:api.go

示例6: CreateJobsRoutes

func CreateJobsRoutes(r martini.Router) {
	jobrunner.Start() // optional: jobrunner.Start(pool int, concurrent int) (10, 1)
	jobrunner.Schedule("@every 5s", ReminderEmails{})
	jobrunner.Schedule("@every 10s", ReminderEmails{})
	entries := jobrunner.Entries()
	fmt.Println(entries[len(entries)-1].ID)
	r.Get("/status", requestJobs)
}
開發者ID:ArthurHlt,項目名稱:microcos,代碼行數:8,代碼來源:jobs_request.go

示例7: setup

func setup(router martini.Router) {
	router.Get("/user/:id", controllers.UserGet)

	router.Put("/user/:id",
		binding.Json(models.User{}),
		binding.ErrorHandler,
		controllers.UserPut)
}
開發者ID:kosuda,項目名稱:martini-test,代碼行數:8,代碼來源:router.go

示例8: initCurrencyApi

func initCurrencyApi(r martini.Router) {
	r.Group("/currencies", func(r martini.Router) {
		r.Get("", func() string {
			var _, body, _ = request.Get("http://api.fixer.io/latest?base=USD").End()
			return body
		})
	})
}
開發者ID:lugovsky,項目名稱:angular-go-seed,代碼行數:8,代碼來源:currencies.go

示例9: InitApplicationsRoutes

func InitApplicationsRoutes(r martini.Router) {
	r.Group("/admin/applications", func(router martini.Router) {
		router.Get("/get/:id", getApplication)
		router.Get("/list", getApplications)
		router.Post("/create", createApplications)
		router.Post("/update", updateApplications)
		router.Post("/delete/:id", deleteApplication)
	})
}
開發者ID:jcgarciam,項目名稱:go-wasab,代碼行數:9,代碼來源:applications.go

示例10: Register

func (lr *ThingRouter) Register(r martini.Router) {

	r.Get("", lr.GetAll)
	r.Get("/:id", lr.GetThing)
	r.Put("/:id", lr.PutThing)
	r.Put("/:id/location", lr.PutThingLocation)
	r.Delete("/:id", lr.DeleteThing)

}
開發者ID:kpernyer,項目名稱:sphere-go-homecloud,代碼行數:9,代碼來源:thing.go

示例11: addResourceRoutes

func addResourceRoutes(r martini.Router) {
	r.Get("/resources", func() string {
		return "All my resources"
	})

	r.Get("/resources/:id", func(p martini.Params) string {
		return "Resources(" + p["id"] + ")"
	})
}
開發者ID:riannucci,項目名稱:fish_basket,代碼行數:9,代碼來源:resource.go

示例12: InitRolesRoutes

func InitRolesRoutes(r martini.Router) {
	r.Group("/admin/roles", func(router martini.Router) {
		router.Get("/get/:id", getRole)
		router.Get("/list", getRoles)
		router.Get("/application/:appId", getRolesByApplication)
		router.Post("/create", createRoles)
		router.Post("/update", updateRoles)
		router.Post("/delete/:id", deleteRole)
	})
}
開發者ID:jcgarciam,項目名稱:go-wasab,代碼行數:10,代碼來源:roles.go

示例13: InitGroupsRoutes

func InitGroupsRoutes(r martini.Router) {
	r.Group("/admin/groups", func(router martini.Router) {
		router.Get("/get/:id", getGroup)
		router.Get("/list", getGroups)
		router.Get("/application/:appId", getGroupsByApplication)
		router.Post("/create", createGroups)
		router.Post("/update", updateGroups)
		router.Post("/delete/:id", deleteGroup)
	})
}
開發者ID:jcgarciam,項目名稱:go-wasab,代碼行數:10,代碼來源:groups.go

示例14: InitUsersRoutes

func InitUsersRoutes(r martini.Router) {
	r.Group("/admin/users", func(router martini.Router) {
		router.Get("/get/:id", getUser)
		router.Get("/list", getUsers)
		router.Get("/get/:id/roles/application/:appId", getUserRoles)
		router.Post("/create", createUsers)
		router.Post("/update", updateUsers)
		router.Post("/delete/:id", deleteUser)
	})
}
開發者ID:jcgarciam,項目名稱:go-wasab,代碼行數:10,代碼來源:users.go

示例15: attachAPI

func attachAPI(api martini.Router) {
	api.Get("/user", getCurrentUser)
	api.Get("/users", getUsers)
	api.Post("/users", newUser)

	api.Get("/users/:name", getUser)
	//api.Put("/users/:name", updateUser)

	api.Get("/users/:name/projects", getProjects)
	//api.Post("/users/:name/projects", newProject)

	//apiGets.HandleFunc("/projects", getProjects)
}
開發者ID:zephyyrr,項目名稱:pi_planner,代碼行數:13,代碼來源:pplanneer.go


注:本文中的github.com/go-martini/martini.Router類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。