Rest::HtmlVis - Rest API visualizer in HTML
Transform perl hash to html. Each key in perl hash is transormed to the piece of html, js and css which are include in main html.
Example:
use Rest::HtmlVis; my $htmlvis = Rest::HtmlVis->new({ events => Rest::HtmlVis::Events }); $htmlvis->html({ events => [ ], links => { rel => 'root', href => /, name => Root resource } form => { GET => { from => { type => 'time', default => time(), } }, POST => { DATA => { type => "text" temperature => 25 }, } } });
HtmlVis has default blocks that are show everytime:
default.baseurl
Set default prefix for links in html. Default is '/static'
default.base
See Rest::HtmlVis::Base.
default.content
See Rest::HtmlVis::Content.
These blocks can be rewrite when the base or content key is set in constructor params.
Create new htmlvis object. You have to specify params for keys that should be transformed.
Define keys in input hash and library that manage this key.
{ events => Rest::HtmlVis::Events }
Third-party js library are primary mapped to /static URL. You have to manage this url by your http server and map this url to share directory. For example in Plack:
use File::ShareDir; my $share = File::ShareDir::dist_dir('Rest-HtmlVis') || "../Rest-HtmlVis/share/"; mount "/static" => Plack::App::File->new(root => $share);
Convert input hash struct to html. Return html string.
http://psgirestapi.dovrtel.cz/
Václav Dovrtěl <vaclav.dovrtel@gmail.com>
Please report any bugs or feature requests to github repository.
Inspired by https://github.com/towhans/hochschober
Copyright 2015- Václav Dovrtěl
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Rest::HtmlVis, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Rest::HtmlVis
CPAN shell
perl -MCPAN -e shell install Rest::HtmlVis
For more information on module installation, please visit the detailed CPAN module installation guide.