protobuf.go — gin Source File
Architecture documentation for protobuf.go, a go file in the gin codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 6da5a1b9_a252_0330_5ba8_989b2c95070d["protobuf.go"] 285f3da5_b453_bac8_eb53_efea9feb6bb9["errors"] 6da5a1b9_a252_0330_5ba8_989b2c95070d --> 285f3da5_b453_bac8_eb53_efea9feb6bb9 style 6da5a1b9_a252_0330_5ba8_989b2c95070d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package binding
import (
"errors"
"io"
"net/http"
"google.golang.org/protobuf/proto"
)
type protobufBinding struct{}
func (protobufBinding) Name() string {
return "protobuf"
}
func (b protobufBinding) Bind(req *http.Request, obj any) error {
buf, err := io.ReadAll(req.Body)
if err != nil {
return err
}
return b.BindBody(buf, obj)
}
func (protobufBinding) BindBody(body []byte, obj any) error {
msg, ok := obj.(proto.Message)
if !ok {
return errors.New("obj is not ProtoMessage")
}
if err := proto.Unmarshal(body, msg); err != nil {
return err
}
// Here it's same to return validate(obj), but until now we can't add
// `binding:""` to the struct which automatically generate by gen-proto
return nil
// return validate(obj)
}
Types
Dependencies
- errors
Source
Frequently Asked Questions
What does protobuf.go do?
protobuf.go is a source file in the gin codebase, written in go.
What does protobuf.go depend on?
protobuf.go imports 1 module(s): errors.
Where is protobuf.go in the architecture?
protobuf.go is located at binding/protobuf.go (directory: binding).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free