1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-04-23 11:07:43 +02:00

rename api to gateway

This commit is contained in:
Asim Aslam 2022-07-02 14:42:12 +01:00
parent 3381a9f3db
commit 48d6650f28
2 changed files with 6 additions and 28 deletions

@ -12,9 +12,9 @@ import (
"go-micro.dev/v4/server" "go-micro.dev/v4/server"
) )
// The Api interface provides a way to // The gateway interface provides a way to
// create composable API gateways // create composable API gateways
type Api interface { type Gateway interface {
// Initialise options // Initialise options
Init(...Option) error Init(...Option) error
// Get the options // Get the options
@ -158,28 +158,6 @@ func Validate(e *Endpoint) error {
return nil return nil
} }
/*
Design ideas
// Gateway is an api gateway interface
type Gateway interface {
// Register a http handler
Handle(pattern string, http.Handler)
// Register a route
RegisterRoute(r Route)
// Init initialises the command line.
// It also parses further options.
Init(...Option) error
// Run the gateway
Run() error
}
// NewGateway returns a new api gateway
func NewGateway() Gateway {
return newGateway()
}
*/
// WithEndpoint returns a server.HandlerOption with endpoint metadata set // WithEndpoint returns a server.HandlerOption with endpoint metadata set
// //
// Usage: // Usage:
@ -194,7 +172,7 @@ func WithEndpoint(e *Endpoint) server.HandlerOption {
return server.EndpointMetadata(e.Name, Encode(e)) return server.EndpointMetadata(e.Name, Encode(e))
} }
// NewApi returns a new api gateway // NewGateway returns a new api gateway
func NewApi(opts ...Option) Api { func NewGateway(opts ...Option) Gateway {
return newApi(opts...) return newGateway(opts...)
} }

@ -16,7 +16,7 @@ type api struct {
server server.Server server server.Server
} }
func newApi(opts ...Option) Api { func newGateway(opts ...Option) Gateway {
options := NewOptions(opts...) options := NewOptions(opts...)
rtr := options.Router rtr := options.Router