// MountAeController "mounts" a Ae resource controller on the given service. func MountAeController(service *goa.Service, ctrl AeController) { initService(service) var h goa.Handler h = func(ctx context.Context, rw http.ResponseWriter, req *http.Request) error { // Check if there was an error loading the request if err := goa.ContextError(ctx); err != nil { return err } // Build the context rctx, err := NewHealthAeContext(ctx, service) if err != nil { return err } return ctrl.Health(rctx) } service.Mux.Handle("GET", "/_ah/health", ctrl.MuxHandler("Health", h, nil)) service.LogInfo("mount", "ctrl", "Ae", "action", "Health", "route", "GET /_ah/health") h = func(ctx context.Context, rw http.ResponseWriter, req *http.Request) error { // Check if there was an error loading the request if err := goa.ContextError(ctx); err != nil { return err } // Build the context rctx, err := NewStartAeContext(ctx, service) if err != nil { return err } return ctrl.Start(rctx) } service.Mux.Handle("GET", "/_ah/start", ctrl.MuxHandler("Start", h, nil)) service.LogInfo("mount", "ctrl", "Ae", "action", "Start", "route", "GET /_ah/start") }
// MountSpecController "mounts" a Spec resource controller on the given service. func MountSpecController(service *goa.Service, ctrl SpecController) { initService(service) var h goa.Handler service.Mux.Handle("OPTIONS", "/swagger/spec", ctrl.MuxHandler("preflight", handleSpecOrigin(cors.HandlePreflight()), nil)) h = func(ctx context.Context, rw http.ResponseWriter, req *http.Request) error { // Check if there was an error loading the request if err := goa.ContextError(ctx); err != nil { return err } // Build the context rctx, err := NewShowSpecContext(ctx, service) if err != nil { return err } return ctrl.Show(rctx) } h = handleSpecOrigin(h) service.Mux.Handle("GET", "/swagger/spec", ctrl.MuxHandler("Show", h, nil)) service.LogInfo("mount", "ctrl", "Spec", "action", "Show", "route", "GET /swagger/spec") }
// MountBottleController "mounts" a Bottle resource controller on the given service. func MountBottleController(service *goa.Service, ctrl BottleController) { initService(service) var h goa.Handler h = func(ctx context.Context, rw http.ResponseWriter, req *http.Request) error { // Check if there was an error loading the request if err := goa.ContextError(ctx); err != nil { return err } // Build the context rctx, err := NewCreateBottleContext(ctx, service) if err != nil { return err } // Build the payload if rawPayload := goa.ContextRequest(ctx).Payload; rawPayload != nil { rctx.Payload = rawPayload.(*CreateBottlePayload) } else { return goa.MissingPayloadError() } return ctrl.Create(rctx) } service.Mux.Handle("POST", "/bottles", ctrl.MuxHandler("Create", h, unmarshalCreateBottlePayload)) service.LogInfo("mount", "ctrl", "Bottle", "action", "Create", "route", "POST /bottles") h = func(ctx context.Context, rw http.ResponseWriter, req *http.Request) error { // Check if there was an error loading the request if err := goa.ContextError(ctx); err != nil { return err } // Build the context rctx, err := NewShowBottleContext(ctx, service) if err != nil { return err } return ctrl.Show(rctx) } service.Mux.Handle("GET", "/bottles/:id", ctrl.MuxHandler("Show", h, nil)) service.LogInfo("mount", "ctrl", "Bottle", "action", "Show", "route", "GET /bottles/:id") }
// MountSwaggerController "mounts" a Swagger resource controller on the given service. func MountSwaggerController(service *goa.Service, ctrl SwaggerController) { initService(service) var h goa.Handler h = ctrl.FileHandler("/swagger-ui/*filepath", "swagger-ui/") service.Mux.Handle("GET", "/swagger-ui/*filepath", ctrl.MuxHandler("serve", h, nil)) service.LogInfo("mount", "ctrl", "Swagger", "files", "swagger-ui/", "route", "GET /swagger-ui/*filepath") h = ctrl.FileHandler("/swagger.json", "swagger/swagger.json") service.Mux.Handle("GET", "/swagger.json", ctrl.MuxHandler("serve", h, nil)) service.LogInfo("mount", "ctrl", "Swagger", "files", "swagger/swagger.json", "route", "GET /swagger.json") h = ctrl.FileHandler("/swagger-ui/", "swagger-ui/index.html") service.Mux.Handle("GET", "/swagger-ui/", ctrl.MuxHandler("serve", h, nil)) service.LogInfo("mount", "ctrl", "Swagger", "files", "swagger-ui/index.html", "route", "GET /swagger-ui/") }