Coder Social home page Coder Social logo

Comments (2)

yugui avatar yugui commented on September 24, 2024

I guess both proto3 and grpc-gateway are working fine, but let me confirm.

IIUC, you defined a service which takes an Alerts message as a request, and tried to pass exactly [{"2":"3"}] as an HTTP request body.
Your generated gateway rejected this request because it expects a JSON object as a request body but received an array of JSON objects.

In this case, an example of the request format which your gateway expects is something like

{
    "alert": [
        {
            "m": {
                "1": "2",
                "3": "4"
            }
        },
        {
            "m": {
                "5": "6"
            }
        }
    ]
}

FYI,

  • the gateway accepted {"1": "2"} because JSON unmarshaller just ignores unknown keys.
  • proto3 does not allow repeated map fields but allows repeated message fields which contain maps.

from grpc-gateway.

miekg avatar miekg commented on September 24, 2024

Thanks for your reply. And, yes exactly what you describe. I will work around it.

from grpc-gateway.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.