Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike Amundsen mamund

View GitHub Profile
@gustavohenrique
gustavohenrique / api-rest
Created May 16, 2016
Your storage model is not your object model is not your resource model is not your representation model.
View api-rest
MY DATA MODEL IS NOT MY OBJECT MODEL
first, the data model (SQL, DocStore, FileSystem) is indepdendent of the object model in the program. for example, i might store customer information (including contact info, financial profile, and order history) in a database. and i might have an object model in my code that includes a customerSummary object. this customerSummary is not a data table. it is made up of details from each of the three data tables, tho.
MY OBJECT MODEL IS NOT MY RESOURCE MODEL
my HTTP resources might take into account the *context* of the user (e.g. visitor, customer, sales rep, admin) and offer different resources for each of them that exposes select customer data. e.g. the /public/customers/ resource might show a list of customer names only with a link to see detail if security context supports that. and the /sales/customer/ resource might list each customer along with recent order history and links to contact that customer directly, update the order history, etc. and the /private/customer/
@bradgessler
bradgessler / list.hon
Last active Dec 29, 2015
JSON is too verbose for hypermedia APIs. HON (Hypermedia Object Notation) preserves the readability and implicit data structure of JSON while with the addition of line attributes for URL and pagination metadata. From http://bradgessler.com/articles/hon/
View list.hon
{
name: "Todo List",
items(href: '/lists/1203/items', next_href: "/lists/1203/items?page=2"): [
item(href: '/items/1'): {
description: "Pick up pizza",
status: "completed"
},
item(href: '/items/12'): {
description: "Eat pizza",
status: "non_started"
View resolvable-or-not.xml
<!--
Date: 2013-05-06
Author: @mamund
Note: Some ways to determine when a URI has an associated resolver and whether it SHOULD be resolvable.
-->
<root>
<scheme>
<!-- the scheme portion of the URI can indicate which (if any) resolver should be used -->
<example>
@pmhsfelix
pmhsfelix / oauth2demo.js
Created Nov 16, 2012
OAuth 2 Client demo using Node.js
View oauth2demo.js
(function(){
var querystring = require('querystring');
var url = require('url');
var request = require('request');
var http = require('http');
var util = require('util');
var child_process = require('child_process');
var config = {
@tobyink
tobyink / 00-http.html
Created Nov 17, 2010 — forked from mamund/00-http.html
Describing HTTP Requests and Reponses in RDFa
View 00-http.html
<html
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:http="http://www.w3.org/2006/http#"
xmlns:cnt="http://www.w3.org/2008/content#">
<head>
<title>Example of HTTP in RDFa</title>
<style type="text/css">
div[typeof="http:Request"]
{
border: 1px solid black;