Skip to content

feat: Gaman Wire (HTTP Response By JSON) #41

@angga7togk

Description

@angga7togk

This serves to make your project's response standard, people's habits in creating rest apis sometimes result in inconsistent responses.

standard json response will look like this

{
  "success": false,
  "message": "Bad Request!",
  "errors": {
    "email": ["email required!", "other errors"]
  },
  "data": {...}
}

response template customization:

The function name is still a plan, it will probably change when we start working on it hehe.

app.responseHandle((ctx,beforeRes) => {
  return ctx.send({
    status: beforeRes.status >= 200 && beforeRes.status < 300,
    data: beforeRes.body
  });
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions