Skip to content
This repository was archived by the owner on May 16, 2023. It is now read-only.

Body parser for Deroutex

License

Notifications You must be signed in to change notification settings

routexjs/deroutex_body_parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deroutex Body Parser

Body parser for Deroutex using Deno Body Parser.

Example

import {
  Deroutex,
  JsonBody,
} from "https://raw.githubusercontent.com/routexjs/deroutex/master/mod.ts";
import {
  createBodyParser,
  JsonBodyParser,
} from "https://raw.githubusercontent.com/Cretezy/deno_body_parser/master/mod.ts";

import { createBodyParserMiddleware } from "./mod.ts";

const app = new Deroutex();

app.middleware(createBodyParserMiddleware(
  createBodyParser({
    parsers: [
      new JsonBodyParser(),
    ],
  }),
));

app.any("/", (ctx) => {
  return new JsonBody(ctx.data);
});

await app.listenAndServe(":8000");

View full example

Usage

Use createBodyParserMiddleware to create a Deroutex middleware based on a body parsers.

If one of the parsers run on the request body, ctx.data.body will be set to the result of the parser (and ctx.data.bodyParser will be set to the parser type, such as json/urlencoded/etc)

Support

Since Deno is evolving quickly, only the latest version is officially supported.

Please file feature requests and bugs at the issue tracker.

About

Body parser for Deroutex

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published