Example #1
0
// NewWorkItemLinkController creates a work-item-link controller.
func NewWorkItemLinkController(service *goa.Service, db application.DB) *WorkItemLinkController {
	if db == nil {
		panic("db must not be nil")
	}
	return &WorkItemLinkController{
		Controller: service.NewController("WorkItemLinkController"),
		db:         db,
	}
}
Example #2
0
// MountPreflightController mounts the handlers for the CORS preflight requests onto service.
func MountPreflightController(service goa.Service, spec Specification) {
	for _, res := range spec {
		path := res.Path
		if res.IsPathPrefix {
			if strings.HasSuffix(path, "/") {
				path += "*cors"
			} else {
				path += "/*cors"
			}
		}
		handle := service.ServeMux().Lookup("OPTIONS", path)
		if handle == nil {
			h := func(ctx *goa.Context) error {
				return ctx.Respond(200, nil)
			}
			ctrl := service.NewController("cors")
			service.ServeMux().Handle("OPTIONS", path, ctrl.HandleFunc("preflight", h, nil))
		}
	}
}
Example #3
0
// NewSearchController creates a search controller.
func NewSearchController(service *goa.Service, db application.DB) *SearchController {
	if db == nil {
		panic("db must not be nil")
	}
	return &SearchController{Controller: service.NewController("SearchController"), db: db}
}
Example #4
0
// NewStatusController creates a status controller.
func NewStatusController(service *goa.Service, db *gorm.DB) *StatusController {
	return &StatusController{
		Controller: service.NewController("StatusController"),
		db:         db,
	}
}
Example #5
0
		It("returns the middleware", func() {
			Ω(fmt.Sprintf("%#v", middleware)).Should(Equal(fmt.Sprintf("%#v", goa.Middleware(goaMiddlewareFunc))))
			Ω(mErr).ShouldNot(HaveOccurred())
		})
	})

	Context("with a context", func() {
		var service *goa.Service
		var req *http.Request
		var rw http.ResponseWriter
		var ctx context.Context

		BeforeEach(func() {
			service = goa.New("test")
			ctrl := service.NewController("foo")
			var err error
			req, err = http.NewRequest("GET", "/goo", nil)
			Ω(err).ShouldNot(HaveOccurred())
			rw = new(TestResponseWriter)
			ctx = goa.NewContext(ctrl.Context, rw, req, nil)
			Ω(goa.ContextResponse(ctx).Status).Should(Equal(0))
		})

		Context("using a goa handler", func() {
			BeforeEach(func() {
				var goaHandler goa.Handler = func(ctx context.Context, rw http.ResponseWriter, req *http.Request) error {
					service.Send(ctx, 200, "ok")
					return nil
				}
				input = goaHandler
Example #6
0
// NewIdentityController creates a identity controller.
func NewIdentityController(service *goa.Service, db application.DB) *IdentityController {
	return &IdentityController{Controller: service.NewController("IdentityController"), db: db}
}
Example #7
0
// NewOperandsController creates a operands controller.
func NewOperandsController(service *goa.Service) *OperandsController {
	return &OperandsController{Controller: service.NewController("operands")}
}
Example #8
0
// NewAreaController creates a area controller.
func NewAreaController(service *goa.Service, db application.DB) *AreaController {
	return &AreaController{Controller: service.NewController("AreaController"), db: db}
}
Example #9
0
// Creates a test context
func newContext(service *goa.Service, rw http.ResponseWriter, req *http.Request, params url.Values) context.Context {
	ctrl := service.NewController("test")
	return goa.NewContext(ctrl.Context, rw, req, params)
}
// NewWorkItemCommentsController creates a work-item-relationships-comments controller.
func NewWorkItemCommentsController(service *goa.Service, db application.DB) *WorkItemCommentsController {
	return &WorkItemCommentsController{Controller: service.NewController("WorkItemRelationshipsCommentsController"), db: db}
}
Example #11
0
// NewUserController creates a user controller.
func NewUserController(service *goa.Service, db application.DB, tokenManager token.Manager) *UserController {
	return &UserController{Controller: service.NewController("UserController"), db: db, tokenManager: tokenManager}
}
Example #12
0
// NewSpaceIterationsController creates a space-iterations controller.
func NewSpaceIterationsController(service *goa.Service, db application.DB) *SpaceIterationsController {
	return &SpaceIterationsController{Controller: service.NewController("SpaceIterationsController"), db: db}
}
Example #13
0
// NewIterationController creates a iteration controller.
func NewIterationController(service *goa.Service, db application.DB) *IterationController {
	return &IterationController{Controller: service.NewController("IterationController"), db: db}
}
Example #14
0
// NewUserspaceController creates a userspace controller.
func NewUserspaceController(service *goa.Service, db *gorm.DB) *UserspaceController {
	db.AutoMigrate(&Data{}).AddUniqueIndex("idx_userspace_path", "path")

	return &UserspaceController{Controller: service.NewController("UserspaceController"), db: db}
}
Example #15
0
// NewSwaggerController creates a swagger controller.
func NewSwaggerController(service *goa.Service) *SwaggerController {
	return &SwaggerController{Controller: service.NewController("SwaggerController")}
}
Example #16
0
// NewAuthenticationController creates a authentication controller.
func NewAuthenticationController(service *goa.Service) *AuthenticationController {
	return &AuthenticationController{Controller: service.NewController("authentication")}
}
Example #17
0
// NewRenderController creates a render controller.
func NewRenderController(service *goa.Service) *RenderController {
	return &RenderController{Controller: service.NewController("RenderController")}
}
Example #18
0
// NewWorkitemtypeController creates a workitemtype controller.
func NewWorkitemtypeController(service *goa.Service, db application.DB) *WorkitemtypeController {
	return &WorkitemtypeController{
		Controller: service.NewController("WorkitemtypeController"),
		db:         db,
	}
}
Example #19
0
	var params url.Values
	var logger *testLogger
	var service *goa.Service

	payload := map[string]interface{}{"payload": 42}

	BeforeEach(func() {
		logger = new(testLogger)
		service = newService(logger)

		var err error
		req, err = http.NewRequest("POST", "/goo?param=value", strings.NewReader(`{"payload":42}`))
		Ω(err).ShouldNot(HaveOccurred())
		rw = new(testResponseWriter)
		params = url.Values{"query": []string{"value"}}
		ctrl := service.NewController("test")
		ctx = goa.NewContext(ctrl.Context, rw, req, params)
		goa.ContextRequest(ctx).Payload = payload
	})

	It("logs requests", func() {
		// Add Action name to the context to make sure we log it properly.
		ctx = goa.WithAction(ctx, "goo")

		h := func(ctx context.Context, rw http.ResponseWriter, req *http.Request) error {
			return service.Send(ctx, 200, "ok")
		}
		lg := middleware.LogRequest(true)(h)
		Ω(lg(ctx, rw, req)).ShouldNot(HaveOccurred())
		Ω(logger.InfoEntries).Should(HaveLen(4))
Example #20
0
// NewUsersController creates a users controller.
func NewUsersController(service *goa.Service, db application.DB) *UsersController {
	return &UsersController{Controller: service.NewController("UsersController"), db: db}
}
Example #21
0
					}
					c.SetPayload(payload)
				}
				return nil
			}
			var err error
			reader := strings.NewReader(reqBody)
			request, err = http.NewRequest("POST", "/foo?filters=one&filters=two&filters=three", reader)
			request.Header.Set("Content-Type", "application/json")
			Ω(err).ShouldNot(HaveOccurred())
			rw = new(TestResponseWriter)
			params = url.Values{"id": []string{"42"}, "filters": []string{"one", "two", "three"}}
		})

		JustBeforeEach(func() {
			ctrl := app.NewController(resName)
			handleFunc = ctrl.HandleFunc(actName, handler, unmarshaler)
			handleFunc(rw, request, params)
		})

		Describe("RespondBytes", func() {
			It("sets the context fields", func() {
				Ω(ctx.Request()).Should(Equal(request))
				Ω(ctx.Header()).Should(Equal(rw.Header()))
				Ω(ctx.ResponseStatus()).Should(Equal(respStatus))
				Ω(ctx.ResponseLength()).Should(Equal(len(respContent)))
				p := ctx.Get("id")
				Ω(p).Should(Equal("42"))
				ps := ctx.GetMany("filters")
				Ω(ps).Should(Equal([]string{"one", "two", "three"}))
				var payload string
Example #22
0
	})

	Describe("Use", func() {
		Context("with a valid middleware", func() {
			var m goa.Middleware

			BeforeEach(func() {
				m = middleware.RequestID()
			})

			JustBeforeEach(func() {
				s.Use(m)
			})

			It("adds the middleware", func() {
				ctrl := s.NewController("test")
				Ω(ctrl.MiddlewareChain()).Should(HaveLen(1))
				Ω(ctrl.MiddlewareChain()[0]).Should(BeAssignableToTypeOf(middleware.RequestID()))
			})
		})
	})

	Describe("HandleFunc", func() {
		const resName = "res"
		const actName = "act"
		var handler, unmarshaler goa.Handler
		const respStatus = 200
		var respContent = []byte("response")

		var handleFunc goa.HandleFunc
		var ctx *goa.Context
Example #23
0
// NewBottleController creates a bottle controller.
func NewBottleController(service *goa.Service) *BottleController {
	return &BottleController{Controller: service.NewController("BottleController")}
}
Example #24
0
// NewAeController creates a ae controller.
func NewAeController(service *goa.Service) *AeController {
	return &AeController{Controller: service.NewController("AeController")}
}
Example #25
0
// NewLoginController creates a login controller.
func NewLoginController(service *goa.Service, auth *login.KeycloakOAuthProvider, tokenManager token.Manager) *LoginController {
	return &LoginController{Controller: service.NewController("login"), auth: auth, tokenManager: tokenManager}
}
Example #26
0
// NewTrackerqueryController creates a trackerquery controller.
func NewTrackerqueryController(service *goa.Service, db application.DB, scheduler *remoteworkitem.Scheduler) *TrackerqueryController {
	return &TrackerqueryController{Controller: service.NewController("TrackerqueryController"), db: db, scheduler: scheduler}
}
Example #27
0
// NewCommentsController creates a comments controller.
func NewCommentsController(service *goa.Service, db application.DB) *CommentsController {
	return &CommentsController{Controller: service.NewController("CommentsController"), db: db}
}