func (s *WalkthroughService) Register(h *hitch.Hitch) error {
	var err error

	listMiddlewares := []func(http.Handler) http.Handler{}

	postMiddlewares := []func(http.Handler) http.Handler{}

	getMiddlewares := []func(http.Handler) http.Handler{}

	putMiddlewares := []func(http.Handler) http.Handler{}

	deleteMiddlewares := []func(http.Handler) http.Handler{}

	listMiddlewares, postMiddlewares, getMiddlewares, putMiddlewares, deleteMiddlewares = beforeWalkthroughServiceRegister()

	if err != nil {
		return err
	}

	h.Get("/api/walkthrough", s.walkthroughListHandler(), listMiddlewares...)

	h.Post("/api/walkthrough", s.walkthroughPostHandler(), postMiddlewares...)

	h.Get("/api/walkthrough/:id", s.walkthroughGetHandler(), getMiddlewares...)

	h.Put("/api/walkthrough/:id", s.walkthroughPutHandler(), putMiddlewares...)

	h.Delete("/api/walkthrough/:id", s.walkthroughDeleteHandler(), deleteMiddlewares...)

	afterWalkthroughServiceRegister(s, h)

	return err
}
示例#2
0
func (s *UserService) Register(h *hitch.Hitch) error {
	var err error

	postMiddlewares := []func(http.Handler) http.Handler{}

	getMiddlewares := []func(http.Handler) http.Handler{}

	putMiddlewares := []func(http.Handler) http.Handler{}

	deleteMiddlewares := []func(http.Handler) http.Handler{}

	// HOOK: beforeUserServiceRegister()

	if err != nil {
		return err
	}

	h.Post("/api/user", s.userPostHandler(), postMiddlewares...)

	h.Get("/api/user/:id", s.userGetHandler(), getMiddlewares...)

	h.Put("/api/user/:id", s.userPutHandler(), putMiddlewares...)

	h.Delete("/api/user/:id", s.userDeleteHandler(), deleteMiddlewares...)

	afterUserServiceRegister(h)

	return err
}