javascript - Static API Documentation with embedded API key -
i'm setting api documentation project, , wanted know best tool job is..
the site static except api keys, i'd include in code examples depending on user (the user gets own api key if they're logged in).
how can accomplish this, while maintaining static site (i'm using static-site generator, middleman).
i suggest include little ajax script on pages, perform search-and-replace through page.
on static page have code this:
<!-- empty span in page template --> <span class='api-key'></span>
everywhere want have api keys embedded. script perform simple task of search-and-replace (pseudocode follows, assuming have jquery on page):
$(document).ready(function () { $.get( "/api/key", function( info ) { /* supply credentials if needed */ $('.api-key').html( info ); } });
hope helps.
javascript jquery ruby ajax
No comments:
Post a Comment