Knowledgebase

REST and Resource Design Print

  • 0

The dominant style.

WHAT REST MEANS IN PRACTICE

Addressing things as resources, acted on with standard methods.

WHAT A RESOURCE IS

A noun: a customer, an order, an invoice.

WHAT THE PATH SHOULD CONTAIN

Nouns, plural, in a hierarchy.

WHAT IT SHOULD NOT CONTAIN

Verbs.

WHY

The method is the verb.

WHAT A COLLECTION LOOKS LIKE

A path naming the plural, returning many.

WHAT A SINGLE ITEM LOOKS LIKE

The same path with an identifier appended.

WHAT NESTING SHOWS

Ownership: items belonging to something.

HOW DEEP TO NEST

One level, usually. Beyond that it becomes unwieldy.

WHAT TO DO INSTEAD OF DEEP NESTING

Address the item directly, with filters.

WHAT TO DO ABOUT ACTIONS THAT ARE NOT CREATE, READ, UPDATE OR DELETE

Model them as a resource where possible, or accept a verb sub-path.

WHAT AN EXAMPLE IS

Cancelling an order as a cancellation resource, rather than a cancel action.

WHY THAT HELPS

It gives the action a record, a time and a status.

WHAT TO KEEP CONSISTENT

Naming, casing and pluralisation, throughout.

WHY CONSISTENCY MATTERS MORE THAN THE CHOICE

Callers guess, and consistency makes guessing correct.

WHAT TO AVOID

Mixing singular and plural Different casing in different places


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot