http - RESTful advice: default value for given resource -
i have following rest structure 'keyboard' objects:
get /keyboards/ -> lists user keyboards post /keyboards/ -> creates new keyboard /keyboards/{id} -> specific keyboard id put /keyboards/{id} -> update specific keyboard id delete /keyboards/{id} -> delete specific keyboard id
the front end uses whatever keyboard set users default keyboard, or, if user has no custom keyboard set, returns generic default.
at present, done requesting url:
get /keyboards/default
however, appears little misleading me, resource 'default' change whenever user changes default, , pointer different specific resource.
i'm not sure of more elegant solution this, front-end appear need make 2 requests otherwise:
get /keyboards/ -> revealing default /keyboards/{id} -> mappings associated keyboard
which seems more laborious, 2 step process. first option reasonable one, or missing more elegant implementation?
it's ok have convenience identifiers 'default', 'latest' etc...
get /keyboards/default -> { id: 3,
another option hang default keyboard off of containing/referencing resource if there one. example
get /computer -> { name: foo, defaultkeyboard: 3, ...
if want avoid 2 requests have isdefault on keyboard object.
get /keyboards [ { id: 1, isdefault: false, ... } { id: 3, isdefault: true, ... }
that allows filter via querystring params.
finally, doesn't have or - can have of these convenient api different access patterns.
Comments
Post a Comment