Skip to content

Instantly share code, notes, and snippets.

View martinstannard's full-sized avatar
🏠
working from home

Martin Stannard martinstannard

🏠
working from home
View GitHub Profile
@martinstannard
martinstannard / API.md
Created March 2, 2020 23:40 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

# Get access to a Library object by locale, always scope by Locale
# A library object gives us conveneince methods to access
# books, authors, fiction and non-fiction book code indeicies by locale.
# The files that drive these indices are located in blake/data/models/db/library/[product]/[subject-index].yml
library = BlakeDataModels::Library.new(locale: 'au', name: 'reading_eggspress')
# What series are available in the locale's library?
library.series_names # Generates array ["abc", "blake_novels", "boffin_boy", "brainwaves", ...]
# include this in application controller
module Authentication
protected
# Inclusion hook to make #current_user and #signed_in?
# available as ActionView helper methods.
def self.included(base)
base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method
end
# Returns true or false if the user is signed in.