Exemplo n.º 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,
	}
}
Exemplo n.º 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))
		}
	}
}
Exemplo n.º 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}
}
Exemplo n.º 4
0
// NewStatusController creates a status controller.
func NewStatusController(service *goa.Service, db *gorm.DB) *StatusController {
	return &StatusController{
		Controller: service.NewController("StatusController"),
		db:         db,
	}
}
Exemplo n.º 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
Exemplo n.º 6
0
// NewIdentityController creates a identity controller.
func NewIdentityController(service *goa.Service, db application.DB) *IdentityController {
	return &IdentityController{Controller: service.NewController("IdentityController"), db: db}
}
Exemplo n.º 7
0
// NewOperandsController creates a operands controller.
func NewOperandsController(service *goa.Service) *OperandsController {
	return &OperandsController{Controller: service.NewController("operands")}
}
Exemplo n.º 8
0
// NewAreaController creates a area controller.
func NewAreaController(service *goa.Service, db application.DB) *AreaController {
	return &AreaController{Controller: service.NewController("AreaController"), db: db}
}
Exemplo n.º 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)
}
Exemplo n.º 10
0
// 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}
}
Exemplo n.º 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}
}
Exemplo n.º 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}
}
Exemplo n.º 13
0
// NewIterationController creates a iteration controller.
func NewIterationController(service *goa.Service, db application.DB) *IterationController {
	return &IterationController{Controller: service.NewController("IterationController"), db: db}
}
Exemplo n.º 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}
}
Exemplo n.º 15
0
// NewSwaggerController creates a swagger controller.
func NewSwaggerController(service *goa.Service) *SwaggerController {
	return &SwaggerController{Controller: service.NewController("SwaggerController")}
}
Exemplo n.º 16
0
// NewAuthenticationController creates a authentication controller.
func NewAuthenticationController(service *goa.Service) *AuthenticationController {
	return &AuthenticationController{Controller: service.NewController("authentication")}
}
Exemplo n.º 17
0
// NewRenderController creates a render controller.
func NewRenderController(service *goa.Service) *RenderController {
	return &RenderController{Controller: service.NewController("RenderController")}
}
Exemplo n.º 18
0
// NewWorkitemtypeController creates a workitemtype controller.
func NewWorkitemtypeController(service *goa.Service, db application.DB) *WorkitemtypeController {
	return &WorkitemtypeController{
		Controller: service.NewController("WorkitemtypeController"),
		db:         db,
	}
}
Exemplo n.º 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))
Exemplo n.º 20
0
// NewUsersController creates a users controller.
func NewUsersController(service *goa.Service, db application.DB) *UsersController {
	return &UsersController{Controller: service.NewController("UsersController"), db: db}
}
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 23
0
// NewBottleController creates a bottle controller.
func NewBottleController(service *goa.Service) *BottleController {
	return &BottleController{Controller: service.NewController("BottleController")}
}
Exemplo n.º 24
0
// NewAeController creates a ae controller.
func NewAeController(service *goa.Service) *AeController {
	return &AeController{Controller: service.NewController("AeController")}
}
Exemplo n.º 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}
}
Exemplo n.º 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}
}
Exemplo n.º 27
0
// NewCommentsController creates a comments controller.
func NewCommentsController(service *goa.Service, db application.DB) *CommentsController {
	return &CommentsController{Controller: service.NewController("CommentsController"), db: db}
}