mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-28 08:27:26 +02:00
grpc: rename internal/grpc to pkg/grpc (#1010)
* grpc: rename internal/grpc to pkg/grpc * don't ignore pkg dir * remove debug line
This commit is contained in:
parent
a98d39c5af
commit
091b71f12e
59 changed files with 247 additions and 927 deletions
30
pkg/grpc/session/session.go
Normal file
30
pkg/grpc/session/session.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Package session contains protobuf types for sessions.
|
||||
package session
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
|
||||
"github.com/pomerium/pomerium/pkg/grpc/databroker"
|
||||
)
|
||||
|
||||
// Get gets a session from the databroker.
|
||||
func Get(ctx context.Context, client databroker.DataBrokerServiceClient, sessionID string) (*Session, error) {
|
||||
any, _ := ptypes.MarshalAny(new(Session))
|
||||
|
||||
res, err := client.Get(ctx, &databroker.GetRequest{
|
||||
Type: any.GetTypeUrl(),
|
||||
Id: sessionID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var s Session
|
||||
err = ptypes.UnmarshalAny(res.GetRecord().GetData(), &s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &s, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue