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
a9c358f2
Commit
a9c358f2
authored
Jul 10, 2020
by
Li Feifei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go fmt project
parent
8d26ca04
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
17 deletions
+13
-17
gateway.go
gateway/gateway.go
+10
-12
main.go
main.go
+1
-1
auth.go
middleware/auth.go
+2
-3
main.go
sevice/im_user_relationship/main.go
+0
-1
No files found.
gateway/gateway.go
View file @
a9c358f2
...
...
@@ -2,14 +2,14 @@ package gateway
import
(
"context"
beeLogger
"github.com/beego/bee/logger"
"net/http"
"strings"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"im-microservice/pb"
_
"im-microservice/google_api"
"im-microservice/pb"
beeLogger
"github.com/beego/bee/logger"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
"google.golang.org/grpc"
...
...
@@ -36,8 +36,8 @@ func ProvideHTTP(endpoint string, grpcServer *grpc.Server) *http.Server {
mux
.
Handle
(
"/"
,
gwmux
)
beeLogger
.
Log
.
Success
(
endpoint
+
" HTTP.Listing..."
)
return
&
http
.
Server
{
Addr
:
endpoint
,
Handler
:
grpcHandlerFunc
(
grpcServer
,
mux
),
Addr
:
endpoint
,
Handler
:
grpcHandlerFunc
(
grpcServer
,
mux
),
}
}
...
...
@@ -48,10 +48,10 @@ func grpcHandlerFunc(grpcServer *grpc.Server, otherHandler http.Handler) http.Ha
return
h2c
.
NewHandler
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
if
r
.
Header
.
Get
(
"Appkey"
)
!=
""
{
HeaderValues
=
map
[
string
]
string
{
"Appkey"
:
r
.
Header
.
Get
(
"Appkey"
),
"Nonce"
:
r
.
Header
.
Get
(
"Nonce"
),
"Curtime"
:
r
.
Header
.
Get
(
"Curtime"
),
"Checksum"
:
r
.
Header
.
Get
(
"Checksum"
),
"Appkey"
:
r
.
Header
.
Get
(
"Appkey"
),
"Nonce"
:
r
.
Header
.
Get
(
"Nonce"
),
"Curtime"
:
r
.
Header
.
Get
(
"Curtime"
),
"Checksum"
:
r
.
Header
.
Get
(
"Checksum"
),
}
}
ctx
:=
context
.
WithValue
(
r
.
Context
(),
"Header"
,
HeaderValues
)
...
...
@@ -63,5 +63,3 @@ func grpcHandlerFunc(grpcServer *grpc.Server, otherHandler http.Handler) http.Ha
}),
&
http2
.
Server
{})
}
main.go
View file @
a9c358f2
...
...
@@ -11,7 +11,7 @@ import (
const
(
Address
string
=
"127.0.0.1:8000"
port
=
":50051"
port
=
":50051"
)
func
main
()
{
...
...
middleware/auth.go
View file @
a9c358f2
...
...
@@ -51,7 +51,6 @@ func checksum(req map[string]string) error {
return
nil
}
func
Auth
(
ctx
context
.
Context
,
req
interface
{},
info
*
grpc
.
UnaryServerInfo
,
handler
grpc
.
UnaryHandler
)
(
interface
{},
error
)
{
...
...
@@ -67,10 +66,10 @@ func Auth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
if
request_map
[
"Curtime"
]
==
""
{
return
nil
,
status
.
Error
(
codes
.
NotFound
,
"Curtime不能为空"
)
}
if
request_map
[
"Nonce"
]
==
""
{
if
request_map
[
"Nonce"
]
==
""
{
return
nil
,
status
.
Error
(
codes
.
NotFound
,
"Nonce不能为空"
)
}
if
request_map
[
"Checksum"
]
==
""
{
if
request_map
[
"Checksum"
]
==
""
{
return
nil
,
status
.
Error
(
codes
.
NotFound
,
"Checksum不能为空"
)
}
}
else
{
...
...
sevice/im_user_relationship/main.go
View file @
a9c358f2
...
...
@@ -106,7 +106,6 @@ func (us *UserRelationshipService) ListBlackAndMuteList(ctx context.Context,
return
}
blacklist
,
mutelist
,
err
:=
ListBlackAndMuteListDB
(
in
)
if
err
!=
nil
{
err
=
status
.
Error
(
codes
.
Internal
,
err
.
Error
())
...
...
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