Skip to content

Commit

Permalink
Merge pull request #1 from ElmerZhang/master
Browse files Browse the repository at this point in the history
add protobuf content types for protobufParser
  • Loading branch information
bbridges committed Jul 4, 2019
2 parents 7f7834d + 6a12f8b commit 81b6696
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/koa-protobuf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const parse = require('co-body');
const contentType = require('content-type');
const getRawBody = require('raw-body');
const protobufContentTypes = ['application/x-protobuf', 'application/protobuf', 'application/vnd.google.protobuf'];

/**
* Parse a protobuf message sent by a client.
Expand All @@ -23,7 +24,7 @@ module.exports.protobufParser = function (messageType, options = {}) {
let type = contentType.parse(ctx).type;
let success;

if (type === 'application/x-protobuf') {
if (protobufContentTypes.indexOf(type) > -1) {
success = await _parseProtobuf(ctx, messageType);
} else if (type === 'application/json' && options.parseJson !== false) {
success = await _parseJson(ctx, messageType);
Expand Down

0 comments on commit 81b6696

Please sign in to comment.