Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Running the example

There's a stack.yaml file in this directory, so you can run and build this example project in a familiar manner.

# pull your GHC deps
stack setup

# build the project
stack build

# run the webserver
stack exec example-exe

At this point you should have a webserver running at http://localhost:8080 You'll find available endpoints at the following urls:

List Resource Example

GET /users

{
   "data" : [
      {
         "type" : "User",
         "relationships" : {
            "email" : {
               "links" : {
                  "self" : "/emails/42"
               },
               "data" : {
                  "type" : "Email",
                  "id" : "42"
               }
            }
         },
         "links" : {
            "self" : "/users/1"
         },
         "meta" : null,
         "id" : "1",
         "attributes" : {
            "userFirstName" : "Isaac",
            "userLastName" : "Newton",
            "userId" : 1
         }
      },
      {
         "relationships" : {
            "email" : {
               "links" : {
                  "self" : "/emails/88"
               },
               "data" : {
                  "id" : "88",
                  "type" : "Email"
               }
            }
         },
         "type" : "User",
         "attributes" : {
            "userFirstName" : "Albert",
            "userLastName" : "Einstein",
            "userId" : 2
         },
         "meta" : null,
         "links" : {
            "self" : "/users/2"
         },
         "id" : "2"
      }
   ],
   "meta" : {
      "user-count" : 2
   },
   "links" : {
      "self" : "/users"
   }
}

Singleton Resource Example

GET /users/1

{
   "meta" : null,
   "data" : {
      "id" : "1",
      "attributes" : {
         "userFirstName" : "Isaac",
         "userId" : 1,
         "userLastName" : "Newton"
      },
      "meta" : null,
      "links" : {
         "self" : "/users/1"
      },
      "type" : "User",
      "relationships" : {
         "email" : {
            "links" : {
               "self" : "/emails/42"
            },
            "data" : {
               "id" : "42",
               "type" : "Email"
            }
         }
      }
   },
   "links" : {
      "self" : "/users/1"
   }
}

Error Example

GET /users/3

{
  "error":{
    "status":"404",
    "code":null,
    "id":null,
    "meta":null,
    "title":"Resource Not Found",
    "links":null,
    "detail":"There is no User with id: 3"
  },
  "meta":null,
  "links":{
    "self":"/users/3"
  }
}