2021-02-05 18:31:51 +03:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
2023-04-28 21:59:31 +03:00
|
|
|
"go.unistack.org/micro/v4/codec"
|
|
|
|
"go.unistack.org/micro/v4/metadata"
|
|
|
|
"go.unistack.org/micro/v4/server"
|
2021-04-26 00:43:06 +03:00
|
|
|
)
|
|
|
|
|
2023-05-09 18:38:49 +03:00
|
|
|
var _ server.Request = &rpcRequest{}
|
2021-02-05 18:31:51 +03:00
|
|
|
|
|
|
|
type rpcRequest struct {
|
|
|
|
rw io.ReadWriter
|
2021-04-25 12:02:18 +03:00
|
|
|
payload interface{}
|
|
|
|
codec codec.Codec
|
|
|
|
header metadata.Metadata
|
2021-02-05 18:31:51 +03:00
|
|
|
method string
|
|
|
|
endpoint string
|
|
|
|
contentType string
|
2021-04-25 12:02:18 +03:00
|
|
|
service string
|
2021-02-05 18:31:51 +03:00
|
|
|
stream bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcRequest) ContentType() string {
|
|
|
|
return r.contentType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcRequest) Service() string {
|
|
|
|
return r.service
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcRequest) Method() string {
|
|
|
|
return r.method
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcRequest) Endpoint() string {
|
2021-04-26 00:43:06 +03:00
|
|
|
return r.endpoint
|
2021-02-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcRequest) Codec() codec.Codec {
|
|
|
|
return r.codec
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcRequest) Header() metadata.Metadata {
|
|
|
|
return r.header
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcRequest) Read() ([]byte, error) {
|
|
|
|
f := &codec.Frame{}
|
|
|
|
if err := r.codec.ReadBody(r.rw, f); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return f.Data, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcRequest) Stream() bool {
|
|
|
|
return r.stream
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcRequest) Body() interface{} {
|
|
|
|
return r.payload
|
|
|
|
}
|