From: Michael Wallner Date: Sat, 14 May 2016 10:06:49 +0000 (+0200) Subject: allow text/plain responses X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fseekat;a=commitdiff_plain;h=98264bf4807a1b82ee7d1584ebb73b4bbba58e6e;ds=sidebyside allow text/plain responses --- diff --git a/examples/gistlog.php b/examples/gistlog.php new file mode 100755 index 0000000..455b30d --- /dev/null +++ b/examples/gistlog.php @@ -0,0 +1,30 @@ +#!/usr/bin/env php + "token ".getenv("GUTHUB_TOKEN") +]); + +$api(function($api) { + $gists = yield $api->users->m6w6->gists(); + while ($gists) { + foreach ($gists as $gist) { + foreach ($gist->files as $name => $file) { + if ($name == "blog.md") { + $text = $file->as("raw")->raw();; + $head = $gist->description." ".$gist->created_at; + echo "$head\n"; + echo str_repeat("=", strlen($head))."\n\n"; + echo trim(yield $text); + echo "\n\nThis was my last gistlog, pipe it through \$PAGER if "; + echo "you really want to read it or visit https://gistlog.co/m6w6\n"; + return; + } + } + } + + $gists = yield $gists->next(); + } +}); diff --git a/lib/API/ContentType.php b/lib/API/ContentType.php index e8f75dc..b2eb5fb 100644 --- a/lib/API/ContentType.php +++ b/lib/API/ContentType.php @@ -17,6 +17,7 @@ class ContentType "html" => "self::fromData", "diff" => "self::fromData", "patch" => "self::fromData", + "text/plain"=> "self::fromData", ]; private $type;