rewrite api package

This commit is contained in:
Asim Aslam
2020-10-17 15:33:56 +01:00
parent f2728a7fee
commit 975da990a9
13 changed files with 44 additions and 164 deletions

View File

@@ -2,6 +2,7 @@ package api
import (
"errors"
"net/http"
"regexp"
"strings"
@@ -9,23 +10,24 @@ import (
"github.com/micro/go-micro/v3/server"
)
type Api interface {
// Gateway is an api gateway interface
type Gateway interface {
// Initialise options
Init(...Option) error
// Get the options
Options() Options
// Register a http handler
// Register an endpoint
Register(*Endpoint) error
// Register a route
// Deregister a route
Deregister(*Endpoint) error
// Register http handler
Handle(path string, hd http.Handler)
// Start serving requests
Serve() error
// Implementation of api
String() string
}
type Options struct{}
type Option func(*Options) error
// Endpoint is a mapping between an RPC method and HTTP endpoint
type Endpoint struct {
// RPC Method e.g. Greeter.Hello