Skip to content

doubt about the main example in the tutorial #1799

@amkhlv

Description

@amkhlv

In the More endpoints section of the chapter "Serving an API", we define a type:

type UserAPI2 = "users" :> Get '[JSON] [User]
           :<|> "albert" :> Get '[JSON] User
           :<|> "isaac" :> Get '[JSON] User

and then serve the data:

server2 :: Server UserAPI2
server2 = return users2
     :<|> return albert
     :<|> return isaac

This seems to be error-prone, as I could easily flip, by accident, the two lines :<|> return albert and :<|> return isaac . This would compile fine, leading to great awkwardness at runtime.

Is there a better way of doing this, especially when there are many endpoints?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions