Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
im-microservice
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Li Feifei
im-microservice
Commits
905d0ad5
Commit
905d0ad5
authored
Jul 13, 2020
by
Li Feifei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现 好友关系 聊天室 IM配置 好友申请的api
parent
f1956075
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1294 additions
and
13 deletions
+1294
-13
gateway.go
gateway/gateway.go
+20
-0
im_base.pb.gw.go
pb/im_base.pb.gw.go
+401
-0
im_chat_room.pb.gw.go
pb/im_chat_room.pb.gw.go
+481
-0
im_friend_req.pb.gw.go
pb/im_friend_req.pb.gw.go
+321
-0
im_base.proto
u-proto/im_base.proto
+23
-4
im_chat_room.proto
u-proto/im_chat_room.proto
+29
-5
im_friend_req.proto
u-proto/im_friend_req.proto
+19
-4
No files found.
gateway/gateway.go
View file @
905d0ad5
...
@@ -26,10 +26,30 @@ func ProvideHTTP(endpoint string, grpcServer *grpc.Server) *http.Server {
...
@@ -26,10 +26,30 @@ func ProvideHTTP(endpoint string, grpcServer *grpc.Server) *http.Server {
gwmux
:=
runtime
.
NewServeMux
()
gwmux
:=
runtime
.
NewServeMux
()
//将服务的http处理程序注册到gwmux。处理程序通过endpoint转发请求到grpc端点
//将服务的http处理程序注册到gwmux。处理程序通过endpoint转发请求到grpc端点
// 好友关系
err
:=
pb
.
RegisterUserRelationshipServiceHandlerFromEndpoint
(
ctx
,
gwmux
,
endpoint
,
dopts
)
err
:=
pb
.
RegisterUserRelationshipServiceHandlerFromEndpoint
(
ctx
,
gwmux
,
endpoint
,
dopts
)
if
err
!=
nil
{
if
err
!=
nil
{
beeLogger
.
Log
.
Fatalf
(
"Register Endpoint err: %v"
,
err
)
beeLogger
.
Log
.
Fatalf
(
"Register Endpoint err: %v"
,
err
)
}
}
// IM配置
err
=
pb
.
RegisterConfigureSeviceHandlerFromEndpoint
(
ctx
,
gwmux
,
endpoint
,
dopts
)
if
err
!=
nil
{
beeLogger
.
Log
.
Fatalf
(
"Register Endpoint err: %v"
,
err
)
}
// 聊天室
err
=
pb
.
RegisterChatRoomServiceHandlerFromEndpoint
(
ctx
,
gwmux
,
endpoint
,
dopts
)
if
err
!=
nil
{
beeLogger
.
Log
.
Fatalf
(
"Register Endpoint err: %v"
,
err
)
}
// 好友申请
err
=
pb
.
RegisterImFriendServiceHandlerFromEndpoint
(
ctx
,
gwmux
,
endpoint
,
dopts
)
if
err
!=
nil
{
beeLogger
.
Log
.
Fatalf
(
"Register Endpoint err: %v"
,
err
)
}
//新建mux,它是http的请求复用器
//新建mux,它是http的请求复用器
mux
:=
http
.
NewServeMux
()
mux
:=
http
.
NewServeMux
()
//注册gwmux
//注册gwmux
...
...
pb/im_base.pb.gw.go
0 → 100644
View file @
905d0ad5
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: u-proto/im_base.proto
/*
Package pb is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package
pb
import
(
"context"
"io"
"net/http"
"github.com/golang/protobuf/descriptor"
"github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/status"
)
// Suppress "imported and not used" errors
var
_
codes
.
Code
var
_
io
.
Reader
var
_
status
.
Status
var
_
=
runtime
.
String
var
_
=
utilities
.
NewDoubleArray
var
_
=
descriptor
.
ForMessage
var
(
filter_ConfigureSevice_Select_0
=
&
utilities
.
DoubleArray
{
Encoding
:
map
[
string
]
int
{},
Base
:
[]
int
(
nil
),
Check
:
[]
int
(
nil
)}
)
func
request_ConfigureSevice_Select_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
client
ConfigureSeviceClient
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
GetAllRequest
var
metadata
runtime
.
ServerMetadata
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
if
err
:=
runtime
.
PopulateQueryParameters
(
&
protoReq
,
req
.
Form
,
filter_ConfigureSevice_Select_0
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
client
.
Select
(
ctx
,
&
protoReq
,
grpc
.
Header
(
&
metadata
.
HeaderMD
),
grpc
.
Trailer
(
&
metadata
.
TrailerMD
))
return
msg
,
metadata
,
err
}
func
local_request_ConfigureSevice_Select_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
server
ConfigureSeviceServer
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
GetAllRequest
var
metadata
runtime
.
ServerMetadata
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
if
err
:=
runtime
.
PopulateQueryParameters
(
&
protoReq
,
req
.
Form
,
filter_ConfigureSevice_Select_0
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
server
.
Select
(
ctx
,
&
protoReq
)
return
msg
,
metadata
,
err
}
func
request_ConfigureSevice_Add_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
client
ConfigureSeviceClient
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ConfigureRequest
var
metadata
runtime
.
ServerMetadata
newReader
,
berr
:=
utilities
.
IOReaderFactory
(
req
.
Body
)
if
berr
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
berr
)
}
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
client
.
Add
(
ctx
,
&
protoReq
,
grpc
.
Header
(
&
metadata
.
HeaderMD
),
grpc
.
Trailer
(
&
metadata
.
TrailerMD
))
return
msg
,
metadata
,
err
}
func
local_request_ConfigureSevice_Add_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
server
ConfigureSeviceServer
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ConfigureRequest
var
metadata
runtime
.
ServerMetadata
newReader
,
berr
:=
utilities
.
IOReaderFactory
(
req
.
Body
)
if
berr
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
berr
)
}
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
server
.
Add
(
ctx
,
&
protoReq
)
return
msg
,
metadata
,
err
}
var
(
filter_ConfigureSevice_Delete_0
=
&
utilities
.
DoubleArray
{
Encoding
:
map
[
string
]
int
{},
Base
:
[]
int
(
nil
),
Check
:
[]
int
(
nil
)}
)
func
request_ConfigureSevice_Delete_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
client
ConfigureSeviceClient
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ConfigureDelRequest
var
metadata
runtime
.
ServerMetadata
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
if
err
:=
runtime
.
PopulateQueryParameters
(
&
protoReq
,
req
.
Form
,
filter_ConfigureSevice_Delete_0
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
client
.
Delete
(
ctx
,
&
protoReq
,
grpc
.
Header
(
&
metadata
.
HeaderMD
),
grpc
.
Trailer
(
&
metadata
.
TrailerMD
))
return
msg
,
metadata
,
err
}
func
local_request_ConfigureSevice_Delete_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
server
ConfigureSeviceServer
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ConfigureDelRequest
var
metadata
runtime
.
ServerMetadata
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
if
err
:=
runtime
.
PopulateQueryParameters
(
&
protoReq
,
req
.
Form
,
filter_ConfigureSevice_Delete_0
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
server
.
Delete
(
ctx
,
&
protoReq
)
return
msg
,
metadata
,
err
}
func
request_ConfigureSevice_Update_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
client
ConfigureSeviceClient
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
UpdateRequest
var
metadata
runtime
.
ServerMetadata
newReader
,
berr
:=
utilities
.
IOReaderFactory
(
req
.
Body
)
if
berr
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
berr
)
}
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
client
.
Update
(
ctx
,
&
protoReq
,
grpc
.
Header
(
&
metadata
.
HeaderMD
),
grpc
.
Trailer
(
&
metadata
.
TrailerMD
))
return
msg
,
metadata
,
err
}
func
local_request_ConfigureSevice_Update_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
server
ConfigureSeviceServer
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
UpdateRequest
var
metadata
runtime
.
ServerMetadata
newReader
,
berr
:=
utilities
.
IOReaderFactory
(
req
.
Body
)
if
berr
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
berr
)
}
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
server
.
Update
(
ctx
,
&
protoReq
)
return
msg
,
metadata
,
err
}
// RegisterConfigureSeviceHandlerServer registers the http handlers for service ConfigureSevice to "mux".
// UnaryRPC :call ConfigureSeviceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
func
RegisterConfigureSeviceHandlerServer
(
ctx
context
.
Context
,
mux
*
runtime
.
ServeMux
,
server
ConfigureSeviceServer
)
error
{
mux
.
Handle
(
"GET"
,
pattern_ConfigureSevice_Select_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
local_request_ConfigureSevice_Select_0
(
rctx
,
inboundMarshaler
,
server
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ConfigureSevice_Select_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"POST"
,
pattern_ConfigureSevice_Add_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
local_request_ConfigureSevice_Add_0
(
rctx
,
inboundMarshaler
,
server
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ConfigureSevice_Add_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"DELETE"
,
pattern_ConfigureSevice_Delete_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
local_request_ConfigureSevice_Delete_0
(
rctx
,
inboundMarshaler
,
server
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ConfigureSevice_Delete_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"PUT"
,
pattern_ConfigureSevice_Update_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
local_request_ConfigureSevice_Update_0
(
rctx
,
inboundMarshaler
,
server
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ConfigureSevice_Update_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
return
nil
}
// RegisterConfigureSeviceHandlerFromEndpoint is same as RegisterConfigureSeviceHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func
RegisterConfigureSeviceHandlerFromEndpoint
(
ctx
context
.
Context
,
mux
*
runtime
.
ServeMux
,
endpoint
string
,
opts
[]
grpc
.
DialOption
)
(
err
error
)
{
conn
,
err
:=
grpc
.
Dial
(
endpoint
,
opts
...
)
if
err
!=
nil
{
return
err
}
defer
func
()
{
if
err
!=
nil
{
if
cerr
:=
conn
.
Close
();
cerr
!=
nil
{
grpclog
.
Infof
(
"Failed to close conn to %s: %v"
,
endpoint
,
cerr
)
}
return
}
go
func
()
{
<-
ctx
.
Done
()
if
cerr
:=
conn
.
Close
();
cerr
!=
nil
{
grpclog
.
Infof
(
"Failed to close conn to %s: %v"
,
endpoint
,
cerr
)
}
}()
}()
return
RegisterConfigureSeviceHandler
(
ctx
,
mux
,
conn
)
}
// RegisterConfigureSeviceHandler registers the http handlers for service ConfigureSevice to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func
RegisterConfigureSeviceHandler
(
ctx
context
.
Context
,
mux
*
runtime
.
ServeMux
,
conn
*
grpc
.
ClientConn
)
error
{
return
RegisterConfigureSeviceHandlerClient
(
ctx
,
mux
,
NewConfigureSeviceClient
(
conn
))
}
// RegisterConfigureSeviceHandlerClient registers the http handlers for service ConfigureSevice
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ConfigureSeviceClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ConfigureSeviceClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "ConfigureSeviceClient" to call the correct interceptors.
func
RegisterConfigureSeviceHandlerClient
(
ctx
context
.
Context
,
mux
*
runtime
.
ServeMux
,
client
ConfigureSeviceClient
)
error
{
mux
.
Handle
(
"GET"
,
pattern_ConfigureSevice_Select_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
request_ConfigureSevice_Select_0
(
rctx
,
inboundMarshaler
,
client
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ConfigureSevice_Select_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"POST"
,
pattern_ConfigureSevice_Add_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
request_ConfigureSevice_Add_0
(
rctx
,
inboundMarshaler
,
client
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ConfigureSevice_Add_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"DELETE"
,
pattern_ConfigureSevice_Delete_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
request_ConfigureSevice_Delete_0
(
rctx
,
inboundMarshaler
,
client
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ConfigureSevice_Delete_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"PUT"
,
pattern_ConfigureSevice_Update_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
request_ConfigureSevice_Update_0
(
rctx
,
inboundMarshaler
,
client
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ConfigureSevice_Update_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
return
nil
}
var
(
pattern_ConfigureSevice_Select_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
},
[]
string
{
"nimserver"
,
"config"
,
"get"
},
""
,
runtime
.
AssumeColonVerbOpt
(
true
)))
pattern_ConfigureSevice_Add_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
},
[]
string
{
"nimserver"
,
"config"
,
"add"
},
""
,
runtime
.
AssumeColonVerbOpt
(
true
)))
pattern_ConfigureSevice_Delete_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
},
[]
string
{
"nimserver"
,
"config"
,
"del"
},
""
,
runtime
.
AssumeColonVerbOpt
(
true
)))
pattern_ConfigureSevice_Update_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
},
[]
string
{
"nimserver"
,
"config"
,
"update"
},
""
,
runtime
.
AssumeColonVerbOpt
(
true
)))
)
var
(
forward_ConfigureSevice_Select_0
=
runtime
.
ForwardResponseMessage
forward_ConfigureSevice_Add_0
=
runtime
.
ForwardResponseMessage
forward_ConfigureSevice_Delete_0
=
runtime
.
ForwardResponseMessage
forward_ConfigureSevice_Update_0
=
runtime
.
ForwardResponseMessage
)
pb/im_chat_room.pb.gw.go
0 → 100644
View file @
905d0ad5
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: u-proto/im_chat_room.proto
/*
Package pb is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package
pb
import
(
"context"
"io"
"net/http"
"github.com/golang/protobuf/descriptor"
"github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/status"
)
// Suppress "imported and not used" errors
var
_
codes
.
Code
var
_
io
.
Reader
var
_
status
.
Status
var
_
=
runtime
.
String
var
_
=
utilities
.
NewDoubleArray
var
_
=
descriptor
.
ForMessage
func
request_ChatRoomService_Add_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
client
ChatRoomServiceClient
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ChatRoomAddRequest
var
metadata
runtime
.
ServerMetadata
newReader
,
berr
:=
utilities
.
IOReaderFactory
(
req
.
Body
)
if
berr
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
berr
)
}
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
client
.
Add
(
ctx
,
&
protoReq
,
grpc
.
Header
(
&
metadata
.
HeaderMD
),
grpc
.
Trailer
(
&
metadata
.
TrailerMD
))
return
msg
,
metadata
,
err
}
func
local_request_ChatRoomService_Add_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
server
ChatRoomServiceServer
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ChatRoomAddRequest
var
metadata
runtime
.
ServerMetadata
newReader
,
berr
:=
utilities
.
IOReaderFactory
(
req
.
Body
)
if
berr
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
berr
)
}
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
server
.
Add
(
ctx
,
&
protoReq
)
return
msg
,
metadata
,
err
}
func
request_ChatRoomService_Update_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
client
ChatRoomServiceClient
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ChatRoomUpdateRequest
var
metadata
runtime
.
ServerMetadata
newReader
,
berr
:=
utilities
.
IOReaderFactory
(
req
.
Body
)
if
berr
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
berr
)
}
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
client
.
Update
(
ctx
,
&
protoReq
,
grpc
.
Header
(
&
metadata
.
HeaderMD
),
grpc
.
Trailer
(
&
metadata
.
TrailerMD
))
return
msg
,
metadata
,
err
}
func
local_request_ChatRoomService_Update_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
server
ChatRoomServiceServer
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ChatRoomUpdateRequest
var
metadata
runtime
.
ServerMetadata
newReader
,
berr
:=
utilities
.
IOReaderFactory
(
req
.
Body
)
if
berr
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
berr
)
}
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
server
.
Update
(
ctx
,
&
protoReq
)
return
msg
,
metadata
,
err
}
var
(
filter_ChatRoomService_Delete_0
=
&
utilities
.
DoubleArray
{
Encoding
:
map
[
string
]
int
{},
Base
:
[]
int
(
nil
),
Check
:
[]
int
(
nil
)}
)
func
request_ChatRoomService_Delete_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
client
ChatRoomServiceClient
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ChatRoomDelRequest
var
metadata
runtime
.
ServerMetadata
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
if
err
:=
runtime
.
PopulateQueryParameters
(
&
protoReq
,
req
.
Form
,
filter_ChatRoomService_Delete_0
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
client
.
Delete
(
ctx
,
&
protoReq
,
grpc
.
Header
(
&
metadata
.
HeaderMD
),
grpc
.
Trailer
(
&
metadata
.
TrailerMD
))
return
msg
,
metadata
,
err
}
func
local_request_ChatRoomService_Delete_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
server
ChatRoomServiceServer
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ChatRoomDelRequest
var
metadata
runtime
.
ServerMetadata
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
if
err
:=
runtime
.
PopulateQueryParameters
(
&
protoReq
,
req
.
Form
,
filter_ChatRoomService_Delete_0
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
server
.
Delete
(
ctx
,
&
protoReq
)
return
msg
,
metadata
,
err
}
var
(
filter_ChatRoomService_Info_0
=
&
utilities
.
DoubleArray
{
Encoding
:
map
[
string
]
int
{},
Base
:
[]
int
(
nil
),
Check
:
[]
int
(
nil
)}
)
func
request_ChatRoomService_Info_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
client
ChatRoomServiceClient
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ChatRoomInfoRequest
var
metadata
runtime
.
ServerMetadata
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
if
err
:=
runtime
.
PopulateQueryParameters
(
&
protoReq
,
req
.
Form
,
filter_ChatRoomService_Info_0
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
client
.
Info
(
ctx
,
&
protoReq
,
grpc
.
Header
(
&
metadata
.
HeaderMD
),
grpc
.
Trailer
(
&
metadata
.
TrailerMD
))
return
msg
,
metadata
,
err
}
func
local_request_ChatRoomService_Info_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
server
ChatRoomServiceServer
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ChatRoomInfoRequest
var
metadata
runtime
.
ServerMetadata
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
if
err
:=
runtime
.
PopulateQueryParameters
(
&
protoReq
,
req
.
Form
,
filter_ChatRoomService_Info_0
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
server
.
Info
(
ctx
,
&
protoReq
)
return
msg
,
metadata
,
err
}
var
(
filter_ChatRoomService_All_0
=
&
utilities
.
DoubleArray
{
Encoding
:
map
[
string
]
int
{},
Base
:
[]
int
(
nil
),
Check
:
[]
int
(
nil
)}
)
func
request_ChatRoomService_All_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
client
ChatRoomServiceClient
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ChatRoomAllRequest
var
metadata
runtime
.
ServerMetadata
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
if
err
:=
runtime
.
PopulateQueryParameters
(
&
protoReq
,
req
.
Form
,
filter_ChatRoomService_All_0
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
client
.
All
(
ctx
,
&
protoReq
,
grpc
.
Header
(
&
metadata
.
HeaderMD
),
grpc
.
Trailer
(
&
metadata
.
TrailerMD
))
return
msg
,
metadata
,
err
}
func
local_request_ChatRoomService_All_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
server
ChatRoomServiceServer
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ChatRoomAllRequest
var
metadata
runtime
.
ServerMetadata
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
if
err
:=
runtime
.
PopulateQueryParameters
(
&
protoReq
,
req
.
Form
,
filter_ChatRoomService_All_0
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
server
.
All
(
ctx
,
&
protoReq
)
return
msg
,
metadata
,
err
}
// RegisterChatRoomServiceHandlerServer registers the http handlers for service ChatRoomService to "mux".
// UnaryRPC :call ChatRoomServiceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
func
RegisterChatRoomServiceHandlerServer
(
ctx
context
.
Context
,
mux
*
runtime
.
ServeMux
,
server
ChatRoomServiceServer
)
error
{
mux
.
Handle
(
"POST"
,
pattern_ChatRoomService_Add_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
local_request_ChatRoomService_Add_0
(
rctx
,
inboundMarshaler
,
server
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ChatRoomService_Add_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"PUT"
,
pattern_ChatRoomService_Update_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
local_request_ChatRoomService_Update_0
(
rctx
,
inboundMarshaler
,
server
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ChatRoomService_Update_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"DELETE"
,
pattern_ChatRoomService_Delete_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
local_request_ChatRoomService_Delete_0
(
rctx
,
inboundMarshaler
,
server
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ChatRoomService_Delete_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"GET"
,
pattern_ChatRoomService_Info_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
local_request_ChatRoomService_Info_0
(
rctx
,
inboundMarshaler
,
server
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ChatRoomService_Info_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"GET"
,
pattern_ChatRoomService_All_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
local_request_ChatRoomService_All_0
(
rctx
,
inboundMarshaler
,
server
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ChatRoomService_All_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
return
nil
}
// RegisterChatRoomServiceHandlerFromEndpoint is same as RegisterChatRoomServiceHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func
RegisterChatRoomServiceHandlerFromEndpoint
(
ctx
context
.
Context
,
mux
*
runtime
.
ServeMux
,
endpoint
string
,
opts
[]
grpc
.
DialOption
)
(
err
error
)
{
conn
,
err
:=
grpc
.
Dial
(
endpoint
,
opts
...
)
if
err
!=
nil
{
return
err
}
defer
func
()
{
if
err
!=
nil
{
if
cerr
:=
conn
.
Close
();
cerr
!=
nil
{
grpclog
.
Infof
(
"Failed to close conn to %s: %v"
,
endpoint
,
cerr
)
}
return
}
go
func
()
{
<-
ctx
.
Done
()
if
cerr
:=
conn
.
Close
();
cerr
!=
nil
{
grpclog
.
Infof
(
"Failed to close conn to %s: %v"
,
endpoint
,
cerr
)
}
}()
}()
return
RegisterChatRoomServiceHandler
(
ctx
,
mux
,
conn
)
}
// RegisterChatRoomServiceHandler registers the http handlers for service ChatRoomService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func
RegisterChatRoomServiceHandler
(
ctx
context
.
Context
,
mux
*
runtime
.
ServeMux
,
conn
*
grpc
.
ClientConn
)
error
{
return
RegisterChatRoomServiceHandlerClient
(
ctx
,
mux
,
NewChatRoomServiceClient
(
conn
))
}
// RegisterChatRoomServiceHandlerClient registers the http handlers for service ChatRoomService
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ChatRoomServiceClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ChatRoomServiceClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "ChatRoomServiceClient" to call the correct interceptors.
func
RegisterChatRoomServiceHandlerClient
(
ctx
context
.
Context
,
mux
*
runtime
.
ServeMux
,
client
ChatRoomServiceClient
)
error
{
mux
.
Handle
(
"POST"
,
pattern_ChatRoomService_Add_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
request_ChatRoomService_Add_0
(
rctx
,
inboundMarshaler
,
client
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ChatRoomService_Add_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"PUT"
,
pattern_ChatRoomService_Update_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
request_ChatRoomService_Update_0
(
rctx
,
inboundMarshaler
,
client
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ChatRoomService_Update_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"DELETE"
,
pattern_ChatRoomService_Delete_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
request_ChatRoomService_Delete_0
(
rctx
,
inboundMarshaler
,
client
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ChatRoomService_Delete_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"GET"
,
pattern_ChatRoomService_Info_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
request_ChatRoomService_Info_0
(
rctx
,
inboundMarshaler
,
client
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ChatRoomService_Info_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"GET"
,
pattern_ChatRoomService_All_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
request_ChatRoomService_All_0
(
rctx
,
inboundMarshaler
,
client
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ChatRoomService_All_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
return
nil
}
var
(
pattern_ChatRoomService_Add_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
},
[]
string
{
"nimserver"
,
"chatroom"
,
"create"
},
""
,
runtime
.
AssumeColonVerbOpt
(
true
)))
pattern_ChatRoomService_Update_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
},
[]
string
{
"nimserver"
,
"chatroom"
,
"update"
},
""
,
runtime
.
AssumeColonVerbOpt
(
true
)))
pattern_ChatRoomService_Delete_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
},
[]
string
{
"nimserver"
,
"chatroom"
,
"delete"
},
""
,
runtime
.
AssumeColonVerbOpt
(
true
)))
pattern_ChatRoomService_Info_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
},
[]
string
{
"nimserver"
,
"chatroom"
,
"get"
},
""
,
runtime
.
AssumeColonVerbOpt
(
true
)))
pattern_ChatRoomService_All_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
},
[]
string
{
"nimserver"
,
"chatroom"
,
"getBatch"
},
""
,
runtime
.
AssumeColonVerbOpt
(
true
)))
)
var
(
forward_ChatRoomService_Add_0
=
runtime
.
ForwardResponseMessage
forward_ChatRoomService_Update_0
=
runtime
.
ForwardResponseMessage
forward_ChatRoomService_Delete_0
=
runtime
.
ForwardResponseMessage
forward_ChatRoomService_Info_0
=
runtime
.
ForwardResponseMessage
forward_ChatRoomService_All_0
=
runtime
.
ForwardResponseMessage
)
pb/im_friend_req.pb.gw.go
0 → 100644
View file @
905d0ad5
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: u-proto/im_friend_req.proto
/*
Package pb is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package
pb
import
(
"context"
"io"
"net/http"
"github.com/golang/protobuf/descriptor"
"github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/status"
)
// Suppress "imported and not used" errors
var
_
codes
.
Code
var
_
io
.
Reader
var
_
status
.
Status
var
_
=
runtime
.
String
var
_
=
utilities
.
NewDoubleArray
var
_
=
descriptor
.
ForMessage
var
(
filter_ImFriendService_All_0
=
&
utilities
.
DoubleArray
{
Encoding
:
map
[
string
]
int
{},
Base
:
[]
int
(
nil
),
Check
:
[]
int
(
nil
)}
)
func
request_ImFriendService_All_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
client
ImFriendServiceClient
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ImFriendListReq
var
metadata
runtime
.
ServerMetadata
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
if
err
:=
runtime
.
PopulateQueryParameters
(
&
protoReq
,
req
.
Form
,
filter_ImFriendService_All_0
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
client
.
All
(
ctx
,
&
protoReq
,
grpc
.
Header
(
&
metadata
.
HeaderMD
),
grpc
.
Trailer
(
&
metadata
.
TrailerMD
))
return
msg
,
metadata
,
err
}
func
local_request_ImFriendService_All_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
server
ImFriendServiceServer
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ImFriendListReq
var
metadata
runtime
.
ServerMetadata
if
err
:=
req
.
ParseForm
();
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
if
err
:=
runtime
.
PopulateQueryParameters
(
&
protoReq
,
req
.
Form
,
filter_ImFriendService_All_0
);
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
server
.
All
(
ctx
,
&
protoReq
)
return
msg
,
metadata
,
err
}
func
request_ImFriendService_Add_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
client
ImFriendServiceClient
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ImFriendAddReq
var
metadata
runtime
.
ServerMetadata
newReader
,
berr
:=
utilities
.
IOReaderFactory
(
req
.
Body
)
if
berr
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
berr
)
}
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
client
.
Add
(
ctx
,
&
protoReq
,
grpc
.
Header
(
&
metadata
.
HeaderMD
),
grpc
.
Trailer
(
&
metadata
.
TrailerMD
))
return
msg
,
metadata
,
err
}
func
local_request_ImFriendService_Add_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
server
ImFriendServiceServer
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ImFriendAddReq
var
metadata
runtime
.
ServerMetadata
newReader
,
berr
:=
utilities
.
IOReaderFactory
(
req
.
Body
)
if
berr
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
berr
)
}
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
server
.
Add
(
ctx
,
&
protoReq
)
return
msg
,
metadata
,
err
}
func
request_ImFriendService_Update_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
client
ImFriendServiceClient
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ImFriendUpdateReq
var
metadata
runtime
.
ServerMetadata
newReader
,
berr
:=
utilities
.
IOReaderFactory
(
req
.
Body
)
if
berr
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
berr
)
}
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
client
.
Update
(
ctx
,
&
protoReq
,
grpc
.
Header
(
&
metadata
.
HeaderMD
),
grpc
.
Trailer
(
&
metadata
.
TrailerMD
))
return
msg
,
metadata
,
err
}
func
local_request_ImFriendService_Update_0
(
ctx
context
.
Context
,
marshaler
runtime
.
Marshaler
,
server
ImFriendServiceServer
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
(
proto
.
Message
,
runtime
.
ServerMetadata
,
error
)
{
var
protoReq
ImFriendUpdateReq
var
metadata
runtime
.
ServerMetadata
newReader
,
berr
:=
utilities
.
IOReaderFactory
(
req
.
Body
)
if
berr
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
berr
)
}
if
err
:=
marshaler
.
NewDecoder
(
newReader
())
.
Decode
(
&
protoReq
);
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
msg
,
err
:=
server
.
Update
(
ctx
,
&
protoReq
)
return
msg
,
metadata
,
err
}
// RegisterImFriendServiceHandlerServer registers the http handlers for service ImFriendService to "mux".
// UnaryRPC :call ImFriendServiceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
func
RegisterImFriendServiceHandlerServer
(
ctx
context
.
Context
,
mux
*
runtime
.
ServeMux
,
server
ImFriendServiceServer
)
error
{
mux
.
Handle
(
"GET"
,
pattern_ImFriendService_All_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
local_request_ImFriendService_All_0
(
rctx
,
inboundMarshaler
,
server
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ImFriendService_All_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"POST"
,
pattern_ImFriendService_Add_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
local_request_ImFriendService_Add_0
(
rctx
,
inboundMarshaler
,
server
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ImFriendService_Add_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"PUT"
,
pattern_ImFriendService_Update_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
local_request_ImFriendService_Update_0
(
rctx
,
inboundMarshaler
,
server
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ImFriendService_Update_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
return
nil
}
// RegisterImFriendServiceHandlerFromEndpoint is same as RegisterImFriendServiceHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func
RegisterImFriendServiceHandlerFromEndpoint
(
ctx
context
.
Context
,
mux
*
runtime
.
ServeMux
,
endpoint
string
,
opts
[]
grpc
.
DialOption
)
(
err
error
)
{
conn
,
err
:=
grpc
.
Dial
(
endpoint
,
opts
...
)
if
err
!=
nil
{
return
err
}
defer
func
()
{
if
err
!=
nil
{
if
cerr
:=
conn
.
Close
();
cerr
!=
nil
{
grpclog
.
Infof
(
"Failed to close conn to %s: %v"
,
endpoint
,
cerr
)
}
return
}
go
func
()
{
<-
ctx
.
Done
()
if
cerr
:=
conn
.
Close
();
cerr
!=
nil
{
grpclog
.
Infof
(
"Failed to close conn to %s: %v"
,
endpoint
,
cerr
)
}
}()
}()
return
RegisterImFriendServiceHandler
(
ctx
,
mux
,
conn
)
}
// RegisterImFriendServiceHandler registers the http handlers for service ImFriendService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func
RegisterImFriendServiceHandler
(
ctx
context
.
Context
,
mux
*
runtime
.
ServeMux
,
conn
*
grpc
.
ClientConn
)
error
{
return
RegisterImFriendServiceHandlerClient
(
ctx
,
mux
,
NewImFriendServiceClient
(
conn
))
}
// RegisterImFriendServiceHandlerClient registers the http handlers for service ImFriendService
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ImFriendServiceClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ImFriendServiceClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "ImFriendServiceClient" to call the correct interceptors.
func
RegisterImFriendServiceHandlerClient
(
ctx
context
.
Context
,
mux
*
runtime
.
ServeMux
,
client
ImFriendServiceClient
)
error
{
mux
.
Handle
(
"GET"
,
pattern_ImFriendService_All_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
request_ImFriendService_All_0
(
rctx
,
inboundMarshaler
,
client
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ImFriendService_All_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"POST"
,
pattern_ImFriendService_Add_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
request_ImFriendService_Add_0
(
rctx
,
inboundMarshaler
,
client
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ImFriendService_Add_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
mux
.
Handle
(
"PUT"
,
pattern_ImFriendService_Update_0
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
pathParams
map
[
string
]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
rctx
,
err
:=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
resp
,
md
,
err
:=
request_ImFriendService_Update_0
(
rctx
,
inboundMarshaler
,
client
,
req
,
pathParams
)
ctx
=
runtime
.
NewServerMetadataContext
(
ctx
,
md
)
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
}
forward_ImFriendService_Update_0
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
resp
,
mux
.
GetForwardResponseOptions
()
...
)
})
return
nil
}
var
(
pattern_ImFriendService_All_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
},
[]
string
{
"nimserver"
,
"firendlist"
,
"getBatch"
},
""
,
runtime
.
AssumeColonVerbOpt
(
true
)))
pattern_ImFriendService_Add_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
},
[]
string
{
"nimserver"
,
"firendlist"
,
"create"
},
""
,
runtime
.
AssumeColonVerbOpt
(
true
)))
pattern_ImFriendService_Update_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
},
[]
string
{
"nimserver"
,
"firendlist"
,
"update"
},
""
,
runtime
.
AssumeColonVerbOpt
(
true
)))
)
var
(
forward_ImFriendService_All_0
=
runtime
.
ForwardResponseMessage
forward_ImFriendService_Add_0
=
runtime
.
ForwardResponseMessage
forward_ImFriendService_Update_0
=
runtime
.
ForwardResponseMessage
)
u-proto/im_base.proto
View file @
905d0ad5
...
@@ -3,6 +3,7 @@ syntax = "proto3";
...
@@ -3,6 +3,7 @@ syntax = "proto3";
package
pb
;
package
pb
;
import
"u-proto/common.proto"
;
import
"u-proto/common.proto"
;
import
"u-proto/google/api/annotations.proto"
;
import
"github.com/mwitkow/go-proto-validators/validator.proto"
;
import
"github.com/mwitkow/go-proto-validators/validator.proto"
;
message
Public
{
message
Public
{
...
@@ -41,8 +42,26 @@ message UpdateRequest {
...
@@ -41,8 +42,26 @@ message UpdateRequest {
}
}
service
ConfigureSevice
{
service
ConfigureSevice
{
rpc
Select
(
GetAllRequest
)
returns
(
GetAllReply
)
{}
rpc
Select
(
GetAllRequest
)
returns
(
GetAllReply
)
{
rpc
Add
(
ConfigureRequest
)
returns
(
ConfigureReply
)
{}
option
(
google.api.http
)
=
{
rpc
Delete
(
ConfigureDelRequest
)
returns
(
ConfigureReply
)
{}
get
:
"/nimserver/config/get"
rpc
Update
(
UpdateRequest
)
returns
(
ConfigureReply
)
{}
};
}
rpc
Add
(
ConfigureRequest
)
returns
(
ConfigureReply
)
{
option
(
google.api.http
)
=
{
post
:
"/nimserver/config/add"
body
:
"*"
};
}
rpc
Delete
(
ConfigureDelRequest
)
returns
(
ConfigureReply
)
{
option
(
google.api.http
)
=
{
delete
:
"/nimserver/config/del"
};
}
rpc
Update
(
UpdateRequest
)
returns
(
ConfigureReply
)
{
option
(
google.api.http
)
=
{
put
:
"/nimserver/config/update"
body
:
"*"
};
}
}
}
u-proto/im_chat_room.proto
View file @
905d0ad5
...
@@ -3,6 +3,7 @@ syntax = "proto3";
...
@@ -3,6 +3,7 @@ syntax = "proto3";
package
pb
;
package
pb
;
import
"u-proto/common.proto"
;
import
"u-proto/common.proto"
;
import
"u-proto/google/api/annotations.proto"
;
import
"github.com/mwitkow/go-proto-validators/validator.proto"
;
import
"github.com/mwitkow/go-proto-validators/validator.proto"
;
// 添加聊天室
// 添加聊天室
...
@@ -73,9 +74,31 @@ message GetChatRoomsReply {
...
@@ -73,9 +74,31 @@ message GetChatRoomsReply {
}
}
service
ChatRoomService
{
service
ChatRoomService
{
rpc
Add
(
ChatRoomAddRequest
)
returns
(
ChatRoomAddReply
)
{}
rpc
Add
(
ChatRoomAddRequest
)
returns
(
ChatRoomAddReply
)
{
rpc
Update
(
ChatRoomUpdateRequest
)
returns
(
ChatRoomUpdateReply
)
{}
option
(
google.api.http
)
=
{
rpc
Delete
(
ChatRoomDelRequest
)
returns
(
ChatRoomDelReply
)
{}
post
:
"/nimserver/chatroom/create"
rpc
Info
(
ChatRoomInfoRequest
)
returns
(
ChatRoomInfoReply
)
{}
body
:
"*"
rpc
All
(
ChatRoomAllRequest
)
returns
(
GetChatRoomsReply
)
{}
};
}
rpc
Update
(
ChatRoomUpdateRequest
)
returns
(
ChatRoomUpdateReply
)
{
option
(
google.api.http
)
=
{
put
:
"/nimserver/chatroom/update"
body
:
"*"
};
}
rpc
Delete
(
ChatRoomDelRequest
)
returns
(
ChatRoomDelReply
)
{
option
(
google.api.http
)
=
{
delete
:
"/nimserver/chatroom/delete"
};
}
rpc
Info
(
ChatRoomInfoRequest
)
returns
(
ChatRoomInfoReply
)
{
option
(
google.api.http
)
=
{
get
:
"/nimserver/chatroom/get"
};
}
rpc
All
(
ChatRoomAllRequest
)
returns
(
GetChatRoomsReply
)
{
option
(
google.api.http
)
=
{
get
:
"/nimserver/chatroom/getBatch"
};
}
}
}
\ No newline at end of file
u-proto/im_friend_req.proto
View file @
905d0ad5
...
@@ -3,9 +3,9 @@ syntax = "proto3";
...
@@ -3,9 +3,9 @@ syntax = "proto3";
package
pb
;
package
pb
;
import
"u-proto/common.proto"
;
import
"u-proto/common.proto"
;
import
"u-proto/google/api/annotations.proto"
;
import
"github.com/mwitkow/go-proto-validators/validator.proto"
;
import
"github.com/mwitkow/go-proto-validators/validator.proto"
;
// 发起添加好友申请
// 发起添加好友申请
message
ImFriendAddReq
{
message
ImFriendAddReq
{
Common
Common
=
1
;
Common
Common
=
1
;
...
@@ -38,7 +38,21 @@ message ImFriendListReply {
...
@@ -38,7 +38,21 @@ message ImFriendListReply {
}
}
service
ImFriendService
{
service
ImFriendService
{
rpc
All
(
ImFriendListReq
)
returns
(
ImFriendListReply
)
{}
rpc
All
(
ImFriendListReq
)
returns
(
ImFriendListReply
)
{
rpc
Add
(
ImFriendAddReq
)
returns
(
ImFriendEmptyReply
)
{}
option
(
google.api.http
)
=
{
rpc
Update
(
ImFriendUpdateReq
)
returns
(
ImFriendEmptyReply
)
{}
get
:
"/nimserver/firendlist/getBatch"
};
}
rpc
Add
(
ImFriendAddReq
)
returns
(
ImFriendEmptyReply
)
{
option
(
google.api.http
)
=
{
post
:
"/nimserver/firendlist/create"
body
:
"*"
};
}
rpc
Update
(
ImFriendUpdateReq
)
returns
(
ImFriendEmptyReply
)
{
option
(
google.api.http
)
=
{
put
:
"/nimserver/firendlist/update"
body
:
"*"
};
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment