Non-collection resource

8 views
Skip to first unread message

Michael Ottoson

unread,
Dec 31, 2019, 12:47:42 PM12/31/19
to Eve REST Framework
Hi All,

As you know, when creating a resource in the domain named, say "people" you get the following behaviour:
  • GET /people returns a collection
  • POST /people adds to the collection
  • GET /people/{id} returns a single resource.

What I want to do is create a resource named, say "foobar" that is not a collection, such that:
  • GET /foobar will return a single resource (e.g. {"foo":true, "bar": false} )
  • PUT /foobar will upsert the one and only foobar resource.

Something like this:

DOMAIN = {
  'people': {
    'schema': {'firstName': {'type': 'string'}, 'lastName': {'type': 'string'}}
  },
  'foobar': {
    'schema': {'foo': {'type': 'boolean'}, 'bar': {'type': 'boolean'}},
    'singleton': True
  }
}

What I've done for now is create flask routes for GET and PUT, but I have to hand-code all of the automatic goodness Eve provides.

Is there a way to create a non-collection resource in the domain?

Reply all
Reply to author
Forward
0 new messages