{"action":"created","comment":{"url":"https://api.github.com/repos/quasar-analytics/quasar/pulls/comments/52226254","id":52226254,"diff_hunk":"@@ -64,104 +60,103 @@ object query {\n     limit.fold(skipped)(l => sql.Binop(skipped, sql.IntLiteral(l.value), sql.Limit))\n   }\n \n-  def service[S[_]: Functor](f: S ~> Task)(implicit R: ReadFile.Ops[S],\n-                                                    W: WriteFile.Ops[S],\n-                                                    M: ManageFile.Ops[S],\n-                                                    Q: QueryFile.Ops[S]): HttpService = {\n+  def service[S[_]: Functor](implicit S0: QueryFileF :<: S,\n+                                      S1: Task :<: S,\n+                                      S2: FileSystemFailureF :<: S): QHttpService[S] = {\n \n     val removePhaseResults = new (FileSystemErrT[PhaseResultT[Free[S,?], ?], ?] ~> FileSystemErrT[Free[S,?], ?]) {\n       def apply[A](t: FileSystemErrT[PhaseResultT[Free[S,?], ?], A]): FileSystemErrT[Free[S,?], A] =\n         EitherT[Free[S,?],FileSystemError,A](t.run.value)\n     }\n \n-    HttpService {\n+    val Q = QueryFile.Ops[S]\n+\n+    QHttpService {\n       case req @ GET -> AsDirPath(path) :? QueryParam(query) +& Offset(offset) +& Limit(limit) => {\n-        handleOffsetLimitParams(offset, limit) { (offset, limit) =>\n-          SQLParser.parseInContext(query, QPath.fromAPath(path)).fold(\n-            formatParsingError,\n-            expr => queryPlan(addOffsetLimit(expr, offset, limit), vars(req)).run.value.fold(\n-              errs => translateSemanticErrors(errs),\n+        (offsetOrInvalid[S](offset) |@| limitOrInvalid[S](limit)) { (offset, limit) =>\n+          SQLParser.parseInContext(query, QPath.fromAPath(path)).map(\n+            expr => queryPlan(addOffsetLimit(expr, offset, limit), vars(req)).run.value.map(\n               logicalPlan => {\n                 val requestedFormat = MessageFormat.fromAccept(req.headers.get(Accept))\n-                formatQuasarDataStreamAsHttpResponse(f)(\n-                  data = Q.evaluate(logicalPlan).translate[FileSystemErrT[Free[S, ?], ?]](removePhaseResults),\n-                  format = requestedFormat)\n+                val formattedData = requestedFormat.encode[FileSystemErrT[Free[S,?], ?]](\n+                  Q.evaluate(logicalPlan).translate[FileSystemErrT[Free[S, ?], ?]](removePhaseResults))\n+                val headers = `Content-Type`(requestedFormat.mediaType) :: requestedFormat.disposition.toList\n+                QuasarResponse.headers.modify(_ ++ headers)(\n+                  QuasarResponse.streaming[S, String, FileSystemError](formattedData))\n               }\n             )\n-          )\n-        }\n+          ).toResponse[S]\n+        }.merge.point[Free[S, ?]]\n       }\n-      case GET -> _ => QueryParameterMustContainQuery\n+      case GET -> _ => queryParameterMustContainQuery[S]\n       case req @ POST -> AsDirPath(path) =>\n-        EntityDecoder.decodeString(req).flatMap { query =>\n-          if (query == \"\") POSTContentMustContainQuery\n+        Free.liftF(S1.inj(EntityDecoder.decodeString(req))).flatMap { query =>\n+          if (query == \"\") postContentMustContainQuery[S]\n           else {\n-            requiredHeader(Destination, req).map { destination =>\n+            requiredHeader2[S](Destination, req).map { destination =>\n               val parseRes = SQLParser.parseInContext(Query(query), QPath.fromAPath(path))\n-                .leftMap(formatParsingError)\n+                .leftMap(_.toResponse[S])\n               val destinationFile = posixCodec.parsePath(\n                 relFile => \\/-(\\/-(relFile)),\n                 absFile => \\/-(-\\/(absFile)),\n-                relDir => -\\/(BadRequest(\"Destination must be a file\")),\n-                absDir => -\\/(BadRequest(\"Destination must be a file\")))(destination.value)\n+                relDir => -\\/(QuasarResponse.error[S](BadRequest, \"Destination must be a file\")),\n+                absDir => -\\/(QuasarResponse.error[S](BadRequest, \"Destination must be a file\")))(destination.value)\n               // Add path of query if destination is a relative file or else just jump through Sandbox hoop\n               val absDestination = destinationFile.flatMap(_.bimap(\n-                absFile => sandbox(rootDir, absFile).map(file0 => rootDir </> file0) \\/> InternalServerError(\"Could not sandbox file\"),\n-                relFile => sandbox(currentDir, relFile).map(file0 => currentDir </> file0).map(file1 => path </> file1) \\/> InternalServerError(\"Could not sandbox file\")\n+                absFile => sandbox(rootDir, absFile).map(file0 => rootDir </> file0) \\/>\n+                  QuasarResponse.error[S](InternalServerError, \"Could not sandbox file\"),\n+                relFile => sandbox(currentDir, relFile).map(file0 =>","path":"web/src/main/scala/quasar/api/services/query.scala","position":116,"original_position":116,"commit_id":"4958066bf6148c0a0f1c56808894f014645a3453","original_commit_id":"4958066bf6148c0a0f1c56808894f014645a3453","user":{"login":"wemrysi","id":32185,"avatar_url":"https://avatars.githubusercontent.com/u/32185?v=3","gravatar_id":"","url":"https://api.github.com/users/wemrysi","html_url":"https://github.com/wemrysi","followers_url":"https://api.github.com/users/wemrysi/followers","following_url":"https://api.github.com/users/wemrysi/following{/other_user}","gists_url":"https://api.github.com/users/wemrysi/gists{/gist_id}","starred_url":"https://api.github.com/users/wemrysi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wemrysi/subscriptions","organizations_url":"https://api.github.com/users/wemrysi/orgs","repos_url":"https://api.github.com/users/wemrysi/repos","events_url":"https://api.github.com/users/wemrysi/events{/privacy}","received_events_url":"https://api.github.com/users/wemrysi/received_events","type":"User","site_admin":false},"body":"Ah, ok I wasn't sure if you were referring to this code or something in `scala-pathy`.","created_at":"2016-02-08T21:14:37Z","updated_at":"2016-02-08T21:14:37Z","html_url":"https://github.com/quasar-analytics/quasar/pull/1081#discussion_r52226254","pull_request_url":"https://api.github.com/repos/quasar-analytics/quasar/pulls/1081","_links":{"self":{"href":"https://api.github.com/repos/quasar-analytics/quasar/pulls/comments/52226254"},"html":{"href":"https://github.com/quasar-analytics/quasar/pull/1081#discussion_r52226254"},"pull_request":{"href":"https://api.github.com/repos/quasar-analytics/quasar/pulls/1081"}}},"pull_request":{"url":"https://api.github.com/repos/quasar-analytics/quasar/pulls/1081","id":58533563,"html_url":"https://github.com/quasar-analytics/quasar/pull/1081","diff_url":"https://github.com/quasar-analytics/quasar/pull/1081.diff","patch_url":"https://github.com/quasar-analytics/quasar/pull/1081.patch","issue_url":"https://api.github.com/repos/quasar-analytics/quasar/issues/1081","number":1081,"state":"open","locked":false,"title":"Convert query service to QHttpService","user":{"login":"drostron","id":318090,"avatar_url":"https://avatars.githubusercontent.com/u/318090?v=3","gravatar_id":"","url":"https://api.github.com/users/drostron","html_url":"https://github.com/drostron","followers_url":"https://api.github.com/users/drostron/followers","following_url":"https://api.github.com/users/drostron/following{/other_user}","gists_url":"https://api.github.com/users/drostron/gists{/gist_id}","starred_url":"https://api.github.com/users/drostron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drostron/subscriptions","organizations_url":"https://api.github.com/users/drostron/orgs","repos_url":"https://api.github.com/users/drostron/repos","events_url":"https://api.github.com/users/drostron/events{/privacy}","received_events_url":"https://api.github.com/users/drostron/received_events","type":"User","site_admin":false},"body":"- delete stale code in services package\r\n- add ToQuasarResponse instances for ParsingError and SemanticErrors\r\n\r\n_paired with @jedesah on this work_","created_at":"2016-02-06T23:34:04Z","updated_at":"2016-02-08T21:14:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"54447cb913ac27559b23b37675f2708410fbd2b7","assignee":{"login":"wemrysi","id":32185,"avatar_url":"https://avatars.githubusercontent.com/u/32185?v=3","gravatar_id":"","url":"https://api.github.com/users/wemrysi","html_url":"https://github.com/wemrysi","followers_url":"https://api.github.com/users/wemrysi/followers","following_url":"https://api.github.com/users/wemrysi/following{/other_user}","gists_url":"https://api.github.com/users/wemrysi/gists{/gist_id}","starred_url":"https://api.github.com/users/wemrysi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wemrysi/subscriptions","organizations_url":"https://api.github.com/users/wemrysi/orgs","repos_url":"https://api.github.com/users/wemrysi/repos","events_url":"https://api.github.com/users/wemrysi/events{/privacy}","received_events_url":"https://api.github.com/users/wemrysi/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/quasar-analytics/quasar/pulls/1081/commits","review_comments_url":"https://api.github.com/repos/quasar-analytics/quasar/pulls/1081/comments","review_comment_url":"https://api.github.com/repos/quasar-analytics/quasar/pulls/comments{/number}","comments_url":"https://api.github.com/repos/quasar-analytics/quasar/issues/1081/comments","statuses_url":"https://api.github.com/repos/quasar-analytics/quasar/statuses/4958066bf6148c0a0f1c56808894f014645a3453","head":{"label":"drostron:topic/refactor_quasar_http_routes_query","ref":"topic/refactor_quasar_http_routes_query","sha":"4958066bf6148c0a0f1c56808894f014645a3453","user":{"login":"drostron","id":318090,"avatar_url":"https://avatars.githubusercontent.com/u/318090?v=3","gravatar_id":"","url":"https://api.github.com/users/drostron","html_url":"https://github.com/drostron","followers_url":"https://api.github.com/users/drostron/followers","following_url":"https://api.github.com/users/drostron/following{/other_user}","gists_url":"https://api.github.com/users/drostron/gists{/gist_id}","starred_url":"https://api.github.com/users/drostron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drostron/subscriptions","organizations_url":"https://api.github.com/users/drostron/orgs","repos_url":"https://api.github.com/users/drostron/repos","events_url":"https://api.github.com/users/drostron/events{/privacy}","received_events_url":"https://api.github.com/users/drostron/received_events","type":"User","site_admin":false},"repo":{"id":42130881,"name":"quasar","full_name":"drostron/quasar","owner":{"login":"drostron","id":318090,"avatar_url":"https://avatars.githubusercontent.com/u/318090?v=3","gravatar_id":"","url":"https://api.github.com/users/drostron","html_url":"https://github.com/drostron","followers_url":"https://api.github.com/users/drostron/followers","following_url":"https://api.github.com/users/drostron/following{/other_user}","gists_url":"https://api.github.com/users/drostron/gists{/gist_id}","starred_url":"https://api.github.com/users/drostron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drostron/subscriptions","organizations_url":"https://api.github.com/users/drostron/orgs","repos_url":"https://api.github.com/users/drostron/repos","events_url":"https://api.github.com/users/drostron/events{/privacy}","received_events_url":"https://api.github.com/users/drostron/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/drostron/quasar","description":"A NoSQL analytics engine that embraces post-relational analytics and pushes computation to the data.","fork":true,"url":"https://api.github.com/repos/drostron/quasar","forks_url":"https://api.github.com/repos/drostron/quasar/forks","keys_url":"https://api.github.com/repos/drostron/quasar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/drostron/quasar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/drostron/quasar/teams","hooks_url":"https://api.github.com/repos/drostron/quasar/hooks","issue_events_url":"https://api.github.com/repos/drostron/quasar/issues/events{/number}","events_url":"https://api.github.com/repos/drostron/quasar/events","assignees_url":"https://api.github.com/repos/drostron/quasar/assignees{/user}","branches_url":"https://api.github.com/repos/drostron/quasar/branches{/branch}","tags_url":"https://api.github.com/repos/drostron/quasar/tags","blobs_url":"https://api.github.com/repos/drostron/quasar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/drostron/quasar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/drostron/quasar/git/refs{/sha}","trees_url":"https://api.github.com/repos/drostron/quasar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/drostron/quasar/statuses/{sha}","languages_url":"https://api.github.com/repos/drostron/quasar/languages","stargazers_url":"https://api.github.com/repos/drostron/quasar/stargazers","contributors_url":"https://api.github.com/repos/drostron/quasar/contributors","subscribers_url":"https://api.github.com/repos/drostron/quasar/subscribers","subscription_url":"https://api.github.com/repos/drostron/quasar/subscription","commits_url":"https://api.github.com/repos/drostron/quasar/commits{/sha}","git_commits_url":"https://api.github.com/repos/drostron/quasar/git/commits{/sha}","comments_url":"https://api.github.com/repos/drostron/quasar/comments{/number}","issue_comment_url":"https://api.github.com/repos/drostron/quasar/issues/comments{/number}","contents_url":"https://api.github.com/repos/drostron/quasar/contents/{+path}","compare_url":"https://api.github.com/repos/drostron/quasar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/drostron/quasar/merges","archive_url":"https://api.github.com/repos/drostron/quasar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/drostron/quasar/downloads","issues_url":"https://api.github.com/repos/drostron/quasar/issues{/number}","pulls_url":"https://api.github.com/repos/drostron/quasar/pulls{/number}","milestones_url":"https://api.github.com/repos/drostron/quasar/milestones{/number}","notifications_url":"https://api.github.com/repos/drostron/quasar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/drostron/quasar/labels{/name}","releases_url":"https://api.github.com/repos/drostron/quasar/releases{/id}","deployments_url":"https://api.github.com/repos/drostron/quasar/deployments","created_at":"2015-09-08T18:22:25Z","updated_at":"2015-10-02T00:47:25Z","pushed_at":"2016-02-07T01:08:33Z","git_url":"git://github.com/drostron/quasar.git","ssh_url":"git@github.com:drostron/quasar.git","clone_url":"https://github.com/drostron/quasar.git","svn_url":"https://github.com/drostron/quasar","homepage":"","size":8967,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"quasar-analytics:topic/refactor_quasar_http_routes","ref":"topic/refactor_quasar_http_routes","sha":"91e6667c323ce071f1ffddf095245faaa78368d7","user":{"login":"quasar-analytics","id":15095906,"avatar_url":"https://avatars.githubusercontent.com/u/15095906?v=3","gravatar_id":"","url":"https://api.github.com/users/quasar-analytics","html_url":"https://github.com/quasar-analytics","followers_url":"https://api.github.com/users/quasar-analytics/followers","following_url":"https://api.github.com/users/quasar-analytics/following{/other_user}","gists_url":"https://api.github.com/users/quasar-analytics/gists{/gist_id}","starred_url":"https://api.github.com/users/quasar-analytics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quasar-analytics/subscriptions","organizations_url":"https://api.github.com/users/quasar-analytics/orgs","repos_url":"https://api.github.com/users/quasar-analytics/repos","events_url":"https://api.github.com/users/quasar-analytics/events{/privacy}","received_events_url":"https://api.github.com/users/quasar-analytics/received_events","type":"Organization","site_admin":false},"repo":{"id":16515058,"name":"quasar","full_name":"quasar-analytics/quasar","owner":{"login":"quasar-analytics","id":15095906,"avatar_url":"https://avatars.githubusercontent.com/u/15095906?v=3","gravatar_id":"","url":"https://api.github.com/users/quasar-analytics","html_url":"https://github.com/quasar-analytics","followers_url":"https://api.github.com/users/quasar-analytics/followers","following_url":"https://api.github.com/users/quasar-analytics/following{/other_user}","gists_url":"https://api.github.com/users/quasar-analytics/gists{/gist_id}","starred_url":"https://api.github.com/users/quasar-analytics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quasar-analytics/subscriptions","organizations_url":"https://api.github.com/users/quasar-analytics/orgs","repos_url":"https://api.github.com/users/quasar-analytics/repos","events_url":"https://api.github.com/users/quasar-analytics/events{/privacy}","received_events_url":"https://api.github.com/users/quasar-analytics/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/quasar-analytics/quasar","description":"A NoSQL analytics engine that embraces post-relational analytics and pushes computation to the data.","fork":false,"url":"https://api.github.com/repos/quasar-analytics/quasar","forks_url":"https://api.github.com/repos/quasar-analytics/quasar/forks","keys_url":"https://api.github.com/repos/quasar-analytics/quasar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quasar-analytics/quasar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quasar-analytics/quasar/teams","hooks_url":"https://api.github.com/repos/quasar-analytics/quasar/hooks","issue_events_url":"https://api.github.com/repos/quasar-analytics/quasar/issues/events{/number}","events_url":"https://api.github.com/repos/quasar-analytics/quasar/events","assignees_url":"https://api.github.com/repos/quasar-analytics/quasar/assignees{/user}","branches_url":"https://api.github.com/repos/quasar-analytics/quasar/branches{/branch}","tags_url":"https://api.github.com/repos/quasar-analytics/quasar/tags","blobs_url":"https://api.github.com/repos/quasar-analytics/quasar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quasar-analytics/quasar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quasar-analytics/quasar/git/refs{/sha}","trees_url":"https://api.github.com/repos/quasar-analytics/quasar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quasar-analytics/quasar/statuses/{sha}","languages_url":"https://api.github.com/repos/quasar-analytics/quasar/languages","stargazers_url":"https://api.github.com/repos/quasar-analytics/quasar/stargazers","contributors_url":"https://api.github.com/repos/quasar-analytics/quasar/contributors","subscribers_url":"https://api.github.com/repos/quasar-analytics/quasar/subscribers","subscription_url":"https://api.github.com/repos/quasar-analytics/quasar/subscription","commits_url":"https://api.github.com/repos/quasar-analytics/quasar/commits{/sha}","git_commits_url":"https://api.github.com/repos/quasar-analytics/quasar/git/commits{/sha}","comments_url":"https://api.github.com/repos/quasar-analytics/quasar/comments{/number}","issue_comment_url":"https://api.github.com/repos/quasar-analytics/quasar/issues/comments{/number}","contents_url":"https://api.github.com/repos/quasar-analytics/quasar/contents/{+path}","compare_url":"https://api.github.com/repos/quasar-analytics/quasar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quasar-analytics/quasar/merges","archive_url":"https://api.github.com/repos/quasar-analytics/quasar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quasar-analytics/quasar/downloads","issues_url":"https://api.github.com/repos/quasar-analytics/quasar/issues{/number}","pulls_url":"https://api.github.com/repos/quasar-analytics/quasar/pulls{/number}","milestones_url":"https://api.github.com/repos/quasar-analytics/quasar/milestones{/number}","notifications_url":"https://api.github.com/repos/quasar-analytics/quasar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quasar-analytics/quasar/labels{/name}","releases_url":"https://api.github.com/repos/quasar-analytics/quasar/releases{/id}","deployments_url":"https://api.github.com/repos/quasar-analytics/quasar/deployments","created_at":"2014-02-04T15:01:27Z","updated_at":"2016-02-06T13:59:21Z","pushed_at":"2016-02-08T19:30:07Z","git_url":"git://github.com/quasar-analytics/quasar.git","ssh_url":"git@github.com:quasar-analytics/quasar.git","clone_url":"https://github.com/quasar-analytics/quasar.git","svn_url":"https://github.com/quasar-analytics/quasar","homepage":"","size":9468,"stargazers_count":211,"watchers_count":211,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":35,"mirror_url":null,"open_issues_count":3,"forks":35,"open_issues":3,"watchers":211,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/quasar-analytics/quasar/pulls/1081"},"html":{"href":"https://github.com/quasar-analytics/quasar/pull/1081"},"issue":{"href":"https://api.github.com/repos/quasar-analytics/quasar/issues/1081"},"comments":{"href":"https://api.github.com/repos/quasar-analytics/quasar/issues/1081/comments"},"review_comments":{"href":"https://api.github.com/repos/quasar-analytics/quasar/pulls/1081/comments"},"review_comment":{"href":"https://api.github.com/repos/quasar-analytics/quasar/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/quasar-analytics/quasar/pulls/1081/commits"},"statuses":{"href":"https://api.github.com/repos/quasar-analytics/quasar/statuses/4958066bf6148c0a0f1c56808894f014645a3453"}}}}