2021-02-05 18:31:51 +03:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
2021-10-26 22:36:04 +03:00
|
|
|
"go.unistack.org/micro/v3/codec"
|
|
|
|
"go.unistack.org/micro/v3/metadata"
|
|
|
|
"go.unistack.org/micro/v3/server"
|
2021-04-26 00:43:06 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
_ server.Request = &rpcRequest{}
|
|
|
|
_ server.Message = &rpcMessage{}
|
2021-02-05 18:31:51 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
type rpcRequest struct {
|
2024-12-27 01:56:04 +03:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
|
|
|
type rpcMessage struct {
|
|
|
|
payload interface{}
|
2021-04-25 12:02:18 +03:00
|
|
|
codec codec.Codec
|
2021-02-05 18:31:51 +03:00
|
|
|
header metadata.Metadata
|
2021-04-25 12:02:18 +03:00
|
|
|
topic string
|
|
|
|
contentType string
|
2021-02-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2024-09-17 12:47:19 +03:00
|
|
|
return nil, nil
|
2021-02-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcRequest) Stream() bool {
|
|
|
|
return r.stream
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcRequest) Body() interface{} {
|
|
|
|
return r.payload
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcMessage) ContentType() string {
|
|
|
|
return r.contentType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcMessage) Topic() string {
|
|
|
|
return r.topic
|
|
|
|
}
|
|
|
|
|
2022-03-21 15:29:40 +03:00
|
|
|
func (r *rpcMessage) Body() interface{} {
|
2021-02-05 18:31:51 +03:00
|
|
|
return r.payload
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcMessage) Header() metadata.Metadata {
|
|
|
|
return r.header
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcMessage) Codec() codec.Codec {
|
|
|
|
return r.codec
|
|
|
|
}
|