# -*- cperl -*-
# -----------------------------------------------------------------------------
package Celaenito::Httpd::Draft;
use strict;
use warnings;
use HTTP::Status;
use Celaenito::Httpd;
use Celaenito::HyperEstraier;
use Celaenito::Permission;

sub handler {
    my ($req, $resp) = @_;
    my $urlid = $req->uri->query_param('urlid');

    CAN_SEE($req) or
      return need_auth_handler(@_);

    EST or return notfound_handler(@_);

    my $doc = EST->draft($urlid);
    $doc or return notfound_handler(@_);

    $resp->header('Content-Type' => 'text/plain; charset=UTF-8');
    $resp->content($doc->dump_draft);
    return RC_OK;
}

1;
