Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

add client interceptor example #71

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
290 changes: 0 additions & 290 deletions Gopkg.lock

This file was deleted.

35 changes: 0 additions & 35 deletions Gopkg.toml

This file was deleted.

22 changes: 12 additions & 10 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
package main

import (
"database/sql"
"flag"
"net"

"github.com/jinzhu/gorm"
"github.com/sirupsen/logrus"

"fmt"
"net"
"net/http"
"time"

"database/sql"

"github.com/infobloxopen/atlas-app-toolkit/gateway"
"github.com/infobloxopen/atlas-app-toolkit/gorm/resource"
"github.com/infobloxopen/atlas-app-toolkit/health"
"github.com/infobloxopen/atlas-app-toolkit/server"
"github.com/infobloxopen/atlas-contacts-app/cmd"
"github.com/infobloxopen/atlas-contacts-app/pkg/pb"

grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/go-grpc-middleware"

"github.com/jinzhu/gorm"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
)

Expand Down Expand Up @@ -137,10 +135,14 @@ func ServeExternal(logger *logrus.Logger) error {
gateway.WithGatewayOptions(
runtime.WithMetadata(gateway.NewPresenceAnnotator("PUT")),
),
gateway.WithDialOptions(
gateway.WithDialOptions(
[]grpc.DialOption{grpc.WithInsecure(), grpc.WithUnaryInterceptor(
grpc_middleware.ChainUnaryClient(
[]grpc.UnaryClientInterceptor{gateway.ClientUnaryInterceptor, gateway.PresenceClientInterceptor()}...,
[]grpc.UnaryClientInterceptor{
grpc_prometheus.UnaryClientInterceptor,
gateway.ClientUnaryInterceptor,
gateway.PresenceClientInterceptor(),
}...,
),
)}...,
),
Expand Down
8 changes: 7 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ FROM golang:1.10.0 AS builder
LABEL stage=server-intermediate
WORKDIR /go/src/github.com/infobloxopen/atlas-contacts-app
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o bin/server ./cmd/server

RUN go build -o bin/server ./cmd/server

# copy the server binary from builder stage; run the server binary
FROM alpine:latest AS runner

# Go programs require libc
RUN mkdir /lib64 && \
ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2

WORKDIR /bin
COPY --from=builder /go/src/github.com/infobloxopen/atlas-contacts-app/bin/server .
COPY pkg/pb/contacts.swagger.json /go/src/github.com/infobloxopen/atlas-contacts-app/www/swagger.json
Expand Down
Loading