forked from utrack/clay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opts.go
48 lines (38 loc) · 1.39 KB
/
opts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package server
import (
"github.com/EridanSilver/clay/v2/server"
"github.com/EridanSilver/clay/v2/server/middlewares/mwhttp"
"github.com/EridanSilver/clay/v2/transport"
"github.com/go-chi/chi"
"google.golang.org/grpc"
)
// Option is an optional setting applied to the Server.
type Option = server.Option
// WithGRPCOpts sets gRPC server options.
func WithGRPCOpts(opts []grpc.ServerOption) Option {
return server.WithGRPCOpts(opts)
}
// WithHTTPPort sets HTTP RPC port to listen on.
// Set same port as main to use single port.
func WithHTTPPort(port int) Option {
return server.WithHTTPPort(port)
}
// WithHTTPMiddlewares sets up HTTP middlewares to work with.
func WithHTTPMiddlewares(mws ...mwhttp.Middleware) Option {
return server.WithHTTPMiddlewares(mws...)
}
// WithGRPCUnaryMiddlewares sets up unary middlewares for gRPC server.
func WithGRPCUnaryMiddlewares(mws ...grpc.UnaryServerInterceptor) Option {
return server.WithGRPCUnaryMiddlewares(mws...)
}
// WithGRPCStreamMiddlewares sets up stream middlewares for gRPC server.
func WithGRPCStreamMiddlewares(mws ...grpc.StreamServerInterceptor) Option {
return server.WithGRPCStreamMiddlewares(mws...)
}
// WithHTTPMux sets existing HTTP muxer to use instead of creating new one.
func WithHTTPMux(mux *chi.Mux) Option {
return server.WithHTTPMux(mux)
}
func WithHTTPRouterMux(mux transport.Router) Option {
return server.WithHTTPRouterMux(mux)
}