TXT.pm 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package Trog::Routes::TXT;
  2. use 5.040;
  3. use re '/aasx';
  4. use warnings FATAL => 'all';
  5. use Trog::Renderer;
  6. our %routes = (
  7. '/text/zone' => {
  8. method => 'GET',
  9. callback => \&zone,
  10. parameters => {},
  11. admin => 1,
  12. },
  13. );
  14. my sub _render ( $code, $headers, %data ) {
  15. return Trog::Renderer->render(
  16. code => $code,
  17. data => \%data,
  18. template => 'zone.tx',
  19. contenttype => 'text/plain',
  20. headers => $headers,
  21. );
  22. }
  23. =head1 Trog::Routes::TXT
  24. Routes which render as text/plain.
  25. =head1 CAVEATS
  26. This module is not wired up to anything. TCMS.pm builds its routing table out
  27. of Trog::Routes::HTML and Trog::Routes::JSON only, so nothing here is reachable
  28. and /text/zone will 404.
  29. =head1 VARIABLES
  30. =over 4
  31. =item %routes
  32. The usual tCMS routing table -- path to method, callback, parameters and
  33. whether the route requires admin.
  34. =back
  35. =head1 ROUTES
  36. =head2 zone
  37. Render zone.tx, this instance's DNS zone file. Admin only.
  38. Note that it passes the query through as-is; zone.tx wants $ip, $nameservers,
  39. $subdomains and friends, so it needs a data gathering pass before it will
  40. render anything.
  41. =cut
  42. sub zone ($query) {
  43. return _render( 200, {}, $query );
  44. }
  45. 1;