Thomas McGoey-Smith

Planning Out my Routes

Side: This is a post in my on going series about Rewriting Has It Shipped Yet in Go.

Planning Out my Routes

So for the next version of Has It Shipped Yet (HISY), I’m incorporating a new feature - theming.

Originally, I hosted my JS widget on S3 and it was just static. It’s main purpose was use jQuery & talk to my API.

This worked pretty well, but everything had to be hardcoded.

With this version, I’m thinking of building a new endpoint that would host a dynamically built JS widget.

This would allow me to hold their customizations and support multiple third-party libraries on an as needed basis.

The Routes

Dynamically embedded widget:

/embed/{store_name}.js

Public API Routes:

/api/{store_name}/orders/{order_id}/lookup
  - Params: Email (email@thomas.codes)

I’m still not 100% sure about including version support.

Mostly because no one would be building directly against my API. Plus, one issue I found was that most of my users had problems with installing/modifying a page’s source code. So if I did want to create a new version, I would either need to build a new app, or try to build some sort of upgrader.

Widget Script

On installation, I would add the widget like this:

<code>
<script src="https://hasitshippedyet.com/embed/not-your-mothers-buttons.js">
<div id="hasitshippedyet-embed"></div>
</code>

From there, the widget would communicate to my API and and then depending on the theme chosen would render out a response.

@tamcgoey on Oct 12, 2015

Enjoyed the article? Subscribe to my newsletter for more.

© Thomas McGoey-Smith (2014-2018). RSS.