修改库名
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/eolinker/goku-eosc/auth/aksk"
|
||||
"github.com/eolinker/goku-eosc/auth/apikey"
|
||||
"github.com/eolinker/goku-eosc/auth/basic"
|
||||
"github.com/eolinker/goku-eosc/auth/jwt"
|
||||
"github.com/eolinker/goku-eosc/discovery/consul"
|
||||
"github.com/eolinker/goku-eosc/discovery/eureka"
|
||||
"github.com/eolinker/goku-eosc/discovery/nacos"
|
||||
"github.com/eolinker/goku-eosc/discovery/static"
|
||||
http_router "github.com/eolinker/goku-eosc/router/http-router"
|
||||
service_http "github.com/eolinker/goku-eosc/service/service-http"
|
||||
store_memory "github.com/eolinker/goku-eosc/store-memory"
|
||||
upstream_http "github.com/eolinker/goku-eosc/upstream/upstream-http"
|
||||
)
|
||||
|
||||
func Register() {
|
||||
storeRegister()
|
||||
|
||||
routerRegister()
|
||||
|
||||
serviceRegister()
|
||||
|
||||
upstreamRegister()
|
||||
|
||||
discoveryRegister()
|
||||
|
||||
authRegister()
|
||||
}
|
||||
|
||||
func authRegister() {
|
||||
basic.Register()
|
||||
apikey.Register()
|
||||
aksk.Register()
|
||||
jwt.Register()
|
||||
}
|
||||
|
||||
func discoveryRegister() {
|
||||
consul.Register()
|
||||
eureka.Register()
|
||||
nacos.Register()
|
||||
static.Register()
|
||||
}
|
||||
|
||||
func storeRegister() {
|
||||
store_memory.Register()
|
||||
}
|
||||
|
||||
func upstreamRegister() {
|
||||
upstream_http.Register()
|
||||
}
|
||||
|
||||
func serviceRegister() {
|
||||
service_http.Register()
|
||||
}
|
||||
|
||||
func routerRegister() {
|
||||
http_router.Register()
|
||||
}
|
||||
60
app/goku/inner.go
Normal file
60
app/goku/inner.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/eolinker/goku/auth/aksk"
|
||||
"github.com/eolinker/goku/auth/apikey"
|
||||
"github.com/eolinker/goku/auth/basic"
|
||||
"github.com/eolinker/goku/auth/jwt"
|
||||
"github.com/eolinker/goku/discovery/consul"
|
||||
"github.com/eolinker/goku/discovery/eureka"
|
||||
"github.com/eolinker/goku/discovery/nacos"
|
||||
"github.com/eolinker/goku/discovery/static"
|
||||
http_router "github.com/eolinker/goku/router/http-router"
|
||||
service_http "github.com/eolinker/goku/service/service-http"
|
||||
store_memory "github.com/eolinker/goku/store-memory"
|
||||
upstream_http "github.com/eolinker/goku/upstream/upstream-http"
|
||||
)
|
||||
|
||||
func Register() {
|
||||
storeRegister()
|
||||
|
||||
routerRegister()
|
||||
|
||||
serviceRegister()
|
||||
|
||||
upstreamRegister()
|
||||
|
||||
discoveryRegister()
|
||||
|
||||
authRegister()
|
||||
}
|
||||
|
||||
func authRegister() {
|
||||
basic.Register()
|
||||
apikey.Register()
|
||||
aksk.Register()
|
||||
jwt.Register()
|
||||
}
|
||||
|
||||
func discoveryRegister() {
|
||||
consul.Register()
|
||||
eureka.Register()
|
||||
nacos.Register()
|
||||
static.Register()
|
||||
}
|
||||
|
||||
func storeRegister() {
|
||||
store_memory.Register()
|
||||
}
|
||||
|
||||
func upstreamRegister() {
|
||||
upstream_http.Register()
|
||||
}
|
||||
|
||||
func serviceRegister() {
|
||||
service_http.Register()
|
||||
}
|
||||
|
||||
func routerRegister() {
|
||||
http_router.Register()
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
reader_yaml "github.com/eolinker/goku-eosc/reader-yaml"
|
||||
reader_yaml "github.com/eolinker/goku/reader-yaml"
|
||||
|
||||
_ "net/http/pprof"
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
"github.com/eolinker/goku-eosc/auth"
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
"github.com/eolinker/goku/auth"
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
)
|
||||
|
||||
//supportTypes 当前驱动支持的authorization type值
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package aksk
|
||||
|
||||
import (
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
)
|
||||
|
||||
var akskConfig = []AKSKConfig{{
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/eolinker/goku-eosc/auth"
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
"github.com/eolinker/goku/auth"
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
)
|
||||
|
||||
const dateHeader = "x-gateway-date"
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
"github.com/eolinker/goku-eosc/auth"
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
"github.com/eolinker/goku/auth"
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
)
|
||||
|
||||
//supportTypes 当前驱动支持的authorization type值
|
||||
|
||||
@@ -3,15 +3,16 @@ package apikey
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"github.com/eolinker/goku-eosc/auth"
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
"errors"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/eolinker/goku/auth"
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
)
|
||||
import "errors"
|
||||
|
||||
var (
|
||||
users = []User{
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -27,7 +27,7 @@ var (
|
||||
|
||||
//CheckSkill 检查能力
|
||||
func CheckSkill(skill string) bool {
|
||||
return skill == "github.com/eolinker/goku-eosc/auth.auth.IAuth"
|
||||
return skill == "github.com/eolinker/goku/auth.auth.IAuth"
|
||||
}
|
||||
|
||||
//IAuth 鉴权接口声明
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
|
||||
"github.com/eolinker/goku-eosc/auth"
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
"github.com/eolinker/goku/auth"
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
)
|
||||
|
||||
//supportTypes 当前驱动支持的authorization type值
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/eolinker/goku-eosc/auth"
|
||||
"github.com/eolinker/goku/auth"
|
||||
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
"github.com/eolinker/goku-eosc/auth"
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
"github.com/eolinker/goku/auth"
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
)
|
||||
|
||||
//supportTypes 当前驱动支持的authorization type值
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package jwt
|
||||
|
||||
import (
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
)
|
||||
|
||||
type responseWriter struct{}
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
)
|
||||
|
||||
type jwtToken struct {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/eolinker/eosc/log"
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
"github.com/hashicorp/consul/api"
|
||||
)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/eolinker/eosc"
|
||||
"github.com/eolinker/eosc/log"
|
||||
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
)
|
||||
|
||||
type consul struct {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
)
|
||||
|
||||
func TestConsulGetNodes(t *testing.T) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ var (
|
||||
|
||||
//CheckSkill 检查目标技能是否符合
|
||||
func CheckSkill(skill string) bool {
|
||||
return skill == "github.com/eolinker/goku-eosc/discovery.discovery.IDiscovery"
|
||||
return skill == "github.com/eolinker/goku/discovery.discovery.IDiscovery"
|
||||
}
|
||||
|
||||
//IDiscovery 服务发现接口
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"net/url"
|
||||
|
||||
"github.com/eolinker/eosc/log"
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
)
|
||||
|
||||
type client struct {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/eolinker/eosc/log"
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
)
|
||||
|
||||
type eureka struct {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
)
|
||||
|
||||
func TestGetApp(t *testing.T) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
"github.com/eolinker/eosc/log"
|
||||
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
)
|
||||
|
||||
type client struct {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/eolinker/eosc/log"
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
)
|
||||
|
||||
func TestGetApp(t *testing.T) {
|
||||
|
||||
@@ -10,10 +10,10 @@ import (
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
health_check_http "github.com/eolinker/goku-eosc/health-check-http"
|
||||
health_check_http "github.com/eolinker/goku/health-check-http"
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
)
|
||||
|
||||
const name = "static"
|
||||
|
||||
2
go.mod
2
go.mod
@@ -1,4 +1,4 @@
|
||||
module github.com/eolinker/goku-eosc
|
||||
module github.com/eolinker/goku
|
||||
|
||||
go 1.15
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package health_check_http
|
||||
|
||||
import "github.com/eolinker/goku-eosc/discovery"
|
||||
import "github.com/eolinker/goku/discovery"
|
||||
|
||||
//agent 从属于HTTPCheck,实现了IHealthChecker接口
|
||||
type agent struct {
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/eolinker/eosc/log"
|
||||
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
"github.com/go-basic/uuid"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/valyala/fasthttp"
|
||||
|
||||
access_field "github.com/eolinker/goku-eosc/node/common/access-field"
|
||||
access_field "github.com/eolinker/goku/node/common/access-field"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/valyala/fasthttp"
|
||||
|
||||
http_proxy_request "github.com/eolinker/goku-eosc/node/http-proxy/http-proxy-request"
|
||||
http_proxy_request "github.com/eolinker/goku/node/http-proxy/http-proxy-request"
|
||||
)
|
||||
|
||||
//DoRequest 构造请求
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/eolinker/goku-eosc/node/http-proxy/backend"
|
||||
"github.com/eolinker/goku/node/http-proxy/backend"
|
||||
)
|
||||
|
||||
type response struct {
|
||||
|
||||
@@ -10,9 +10,10 @@ package router
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/eolinker/goku-eosc/router/checker"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/eolinker/goku/router/checker"
|
||||
)
|
||||
|
||||
type RulePath struct {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/eolinker/goku-eosc/router/checker"
|
||||
"github.com/eolinker/goku/router/checker"
|
||||
)
|
||||
|
||||
type testSource map[string]string
|
||||
|
||||
@@ -2,8 +2,8 @@ package http_router
|
||||
|
||||
import (
|
||||
"github.com/eolinker/eosc"
|
||||
router_http "github.com/eolinker/goku-eosc/router/router-http"
|
||||
"github.com/eolinker/goku-eosc/service"
|
||||
router_http "github.com/eolinker/goku/router/router-http"
|
||||
"github.com/eolinker/goku/service"
|
||||
)
|
||||
|
||||
type DriverConfig struct {
|
||||
@@ -14,7 +14,7 @@ type DriverConfig struct {
|
||||
Rules []DriverRule `json:"rules" yaml:"rules"`
|
||||
Protocol string `json:"protocol" yaml:"protocol"`
|
||||
Cert []Cert `json:"cert" yaml:"cert"`
|
||||
Target eosc.RequireId `json:"target" yaml:"target" skill:"github.com/eolinker/goku-eosc/service.service.IService"`
|
||||
Target eosc.RequireId `json:"target" yaml:"target" skill:"github.com/eolinker/goku/service.service.IService"`
|
||||
}
|
||||
|
||||
type DriverRule struct {
|
||||
|
||||
@@ -2,9 +2,10 @@ package http_router
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/eolinker/goku-eosc/service"
|
||||
"reflect"
|
||||
|
||||
"github.com/eolinker/goku/service"
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
)
|
||||
|
||||
@@ -15,32 +16,32 @@ type HttpRouterDriver struct {
|
||||
|
||||
func (h *HttpRouterDriver) Create(id, name string, v interface{}, workers map[eosc.RequireId]interface{}) (eosc.IWorker, error) {
|
||||
conf, iService, err := h.check(v, workers)
|
||||
if err!= nil{
|
||||
return nil,err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewRouter(id,name,conf,iService),nil
|
||||
return NewRouter(id, name, conf, iService), nil
|
||||
}
|
||||
|
||||
func (h*HttpRouterDriver)check(v interface{},workers map[eosc.RequireId]interface{})( *DriverConfig,service.IService,error) {
|
||||
conf,ok:=v.(*DriverConfig)
|
||||
if !ok{
|
||||
return nil, nil,fmt.Errorf("get %s but %s %w",eosc.TypeNameOf(v),eosc.TypeNameOf(new(DriverConfig)),eosc.ErrorRequire)
|
||||
func (h *HttpRouterDriver) check(v interface{}, workers map[eosc.RequireId]interface{}) (*DriverConfig, service.IService, error) {
|
||||
conf, ok := v.(*DriverConfig)
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("get %s but %s %w", eosc.TypeNameOf(v), eosc.TypeNameOf(new(DriverConfig)), eosc.ErrorRequire)
|
||||
}
|
||||
|
||||
ser,has:=workers[conf.Target]
|
||||
if !has{
|
||||
return nil,nil,fmt.Errorf("target %w",eosc.ErrorRequire)
|
||||
ser, has := workers[conf.Target]
|
||||
if !has {
|
||||
return nil, nil, fmt.Errorf("target %w", eosc.ErrorRequire)
|
||||
}
|
||||
target,ok:=ser.(service.IService)
|
||||
if !ok{
|
||||
return nil,nil,fmt.Errorf("target %w",eosc.ErrorNotGetSillForRequire)
|
||||
}
|
||||
return conf,target,nil
|
||||
target, ok := ser.(service.IService)
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("target %w", eosc.ErrorNotGetSillForRequire)
|
||||
}
|
||||
return conf, target, nil
|
||||
|
||||
}
|
||||
func NewHttpRouter(profession, name, label, desc string, params map[string]string) *HttpRouterDriver {
|
||||
return &HttpRouterDriver{
|
||||
configType:reflect.TypeOf(new(DriverConfig)),
|
||||
configType: reflect.TypeOf(new(DriverConfig)),
|
||||
info: eosc.DriverInfo{
|
||||
Name: name,
|
||||
Label: label,
|
||||
|
||||
@@ -2,8 +2,8 @@ package http_router
|
||||
|
||||
import (
|
||||
"github.com/eolinker/eosc"
|
||||
router_http "github.com/eolinker/goku-eosc/router/router-http"
|
||||
"github.com/eolinker/goku-eosc/service"
|
||||
router_http "github.com/eolinker/goku/router/router-http"
|
||||
"github.com/eolinker/goku/service"
|
||||
)
|
||||
|
||||
type Router struct {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package router_http
|
||||
|
||||
import (
|
||||
"github.com/eolinker/goku-eosc/router"
|
||||
"github.com/eolinker/goku-eosc/router/checker"
|
||||
"github.com/eolinker/goku-eosc/service"
|
||||
"github.com/eolinker/goku/router"
|
||||
"github.com/eolinker/goku/router/checker"
|
||||
"github.com/eolinker/goku/service"
|
||||
)
|
||||
|
||||
type HeaderItem struct {
|
||||
|
||||
@@ -11,9 +11,9 @@ package router_http
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/eolinker/goku-eosc/router"
|
||||
"github.com/eolinker/goku-eosc/router/checker"
|
||||
"github.com/eolinker/goku-eosc/service"
|
||||
"github.com/eolinker/goku/router"
|
||||
"github.com/eolinker/goku/router/checker"
|
||||
"github.com/eolinker/goku/service"
|
||||
)
|
||||
|
||||
var _ service.IRouterEndpoint = (*EndPoint)(nil)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package router_http
|
||||
|
||||
import (
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
|
||||
"github.com/eolinker/goku-eosc/router"
|
||||
"github.com/eolinker/goku-eosc/service"
|
||||
"github.com/eolinker/goku/router"
|
||||
"github.com/eolinker/goku/service"
|
||||
)
|
||||
|
||||
type IMatcher interface {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package router_http
|
||||
|
||||
import (
|
||||
"github.com/eolinker/goku-eosc/router"
|
||||
"github.com/eolinker/goku-eosc/router/checker"
|
||||
"github.com/eolinker/goku-eosc/service"
|
||||
"github.com/eolinker/goku/router"
|
||||
"github.com/eolinker/goku/router/checker"
|
||||
"github.com/eolinker/goku/service"
|
||||
)
|
||||
|
||||
func parse(cs []*Config) (IMatcher, error) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package router_http
|
||||
import (
|
||||
"sync"
|
||||
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
|
||||
"github.com/valyala/fasthttp"
|
||||
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/eolinker/goku-eosc/router/checker"
|
||||
"github.com/eolinker/goku/router/checker"
|
||||
)
|
||||
|
||||
type ISource interface {
|
||||
Get(cmd string)(string,bool)
|
||||
Get(cmd string) (string, bool)
|
||||
}
|
||||
|
||||
type IRouter interface {
|
||||
Router(source ISource)(endpoint IEndPoint,has bool)
|
||||
Router(source ISource) (endpoint IEndPoint, has bool)
|
||||
}
|
||||
|
||||
type Routers []IRouter
|
||||
|
||||
func (rs Routers) Router(source ISource) (IEndPoint, bool) {
|
||||
for _,r:=range rs{
|
||||
if target,has:=r.Router(source);has{
|
||||
return target,has
|
||||
func (rs Routers) Router(source ISource) (IEndPoint, bool) {
|
||||
for _, r := range rs {
|
||||
if target, has := r.Router(source); has {
|
||||
return target, has
|
||||
}
|
||||
}
|
||||
return nil, false
|
||||
@@ -29,33 +29,30 @@ type Node struct {
|
||||
equals map[string]IRouter
|
||||
|
||||
checkers []checker.Checker
|
||||
nodes []IRouter
|
||||
|
||||
nodes []IRouter
|
||||
}
|
||||
|
||||
func (n *Node) Router(source ISource) (IEndPoint, bool) {
|
||||
|
||||
v, has := source.Get(n.cmd)
|
||||
|
||||
func (n *Node) Router(source ISource) (IEndPoint, bool) {
|
||||
|
||||
v,has:=source.Get(n.cmd)
|
||||
|
||||
if has{
|
||||
if child,ok:= n.equals[v];ok{
|
||||
if target,ok:=child.Router(source);ok{
|
||||
return target,true
|
||||
if has {
|
||||
if child, ok := n.equals[v]; ok {
|
||||
if target, ok := child.Router(source); ok {
|
||||
return target, true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for i,c:=range n.checkers{
|
||||
if c.Check(v,has){
|
||||
if target,ok:=n.nodes[i].Router(source);ok{
|
||||
return target,true
|
||||
for i, c := range n.checkers {
|
||||
if c.Check(v, has) {
|
||||
if target, ok := n.nodes[i].Router(source); ok {
|
||||
return target, true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil,false
|
||||
return nil, false
|
||||
|
||||
}
|
||||
|
||||
@@ -64,11 +61,11 @@ type NodeShut struct {
|
||||
endpoint IEndPoint
|
||||
}
|
||||
|
||||
func (n *NodeShut) Router(source ISource) (IEndPoint, bool) {
|
||||
if e ,has:=n.next.Router(source);has{
|
||||
return e,has
|
||||
func (n *NodeShut) Router(source ISource) (IEndPoint, bool) {
|
||||
if e, has := n.next.Router(source); has {
|
||||
return e, has
|
||||
}
|
||||
return n.endpoint,true
|
||||
return n.endpoint, true
|
||||
}
|
||||
|
||||
func NewNodeShut(next IRouter, endpoint IEndPoint) IRouter {
|
||||
|
||||
@@ -17,8 +17,8 @@ type Config struct {
|
||||
Scheme string `json:"scheme"`
|
||||
RewriteURL string `json:"rewrite_url"`
|
||||
ProxyMethod string `json:"proxy_method"`
|
||||
Auth []eosc.RequireId `json:"auth" skill:"github.com/eolinker/goku-eosc/auth.auth.IAuth"`
|
||||
Upstream eosc.RequireId `json:"upstream" skill:"github.com/eolinker/goku-eosc/upstream.upstream.IUpstream" require:"false"`
|
||||
Auth []eosc.RequireId `json:"auth" skill:"github.com/eolinker/goku/auth.auth.IAuth"`
|
||||
Upstream eosc.RequireId `json:"upstream" skill:"github.com/eolinker/goku/upstream.upstream.IUpstream" require:"false"`
|
||||
}
|
||||
|
||||
var validMethods = []string{
|
||||
|
||||
@@ -8,21 +8,21 @@ import (
|
||||
|
||||
"github.com/valyala/fasthttp"
|
||||
|
||||
http_proxy "github.com/eolinker/goku-eosc/node/http-proxy"
|
||||
"github.com/eolinker/goku-eosc/utils"
|
||||
http_proxy "github.com/eolinker/goku/node/http-proxy"
|
||||
"github.com/eolinker/goku/utils"
|
||||
|
||||
"github.com/eolinker/eosc/log"
|
||||
|
||||
"github.com/eolinker/goku-eosc/auth"
|
||||
"github.com/eolinker/goku/auth"
|
||||
|
||||
"github.com/eolinker/goku-eosc/router/checker"
|
||||
"github.com/eolinker/goku/router/checker"
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
"github.com/eolinker/goku-eosc/upstream"
|
||||
"github.com/eolinker/goku/upstream"
|
||||
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
|
||||
"github.com/eolinker/goku-eosc/service"
|
||||
"github.com/eolinker/goku/service"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -6,14 +6,14 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/eolinker/goku-eosc/service"
|
||||
"github.com/eolinker/goku/service"
|
||||
|
||||
upstream_http "github.com/eolinker/goku-eosc/upstream/upstream-http"
|
||||
upstream_http "github.com/eolinker/goku/upstream/upstream-http"
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
"github.com/eolinker/goku-eosc/discovery/static"
|
||||
"github.com/eolinker/goku-eosc/upstream"
|
||||
round_robin "github.com/eolinker/goku-eosc/upstream/round-robin"
|
||||
"github.com/eolinker/goku/discovery/static"
|
||||
"github.com/eolinker/goku/upstream"
|
||||
round_robin "github.com/eolinker/goku/upstream/round-robin"
|
||||
)
|
||||
|
||||
type routerDemo struct {
|
||||
|
||||
@@ -3,16 +3,16 @@ package service
|
||||
import (
|
||||
"time"
|
||||
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
"github.com/eolinker/goku-eosc/router/checker"
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
"github.com/eolinker/goku/router/checker"
|
||||
)
|
||||
|
||||
//CheckSkill 检查目标技能是否符合
|
||||
func CheckSkill(skill string) bool {
|
||||
return skill == "github.com/eolinker/goku-eosc/service.service.IService"
|
||||
return skill == "github.com/eolinker/goku/service.service.IService"
|
||||
}
|
||||
|
||||
//IService github.com/eolinker/goku-eosc/service.service.IService
|
||||
//IService github.com/eolinker/goku/service.service.IService
|
||||
type IService interface {
|
||||
Handle(ctx *http_context.Context, router IRouterEndpoint) error
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"errors"
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku-eosc/upstream/balance"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
"github.com/eolinker/goku/upstream/balance"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -3,7 +3,7 @@ package round_robin
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
)
|
||||
|
||||
type discoveryDemo struct {
|
||||
|
||||
@@ -10,5 +10,5 @@ type Config struct {
|
||||
Scheme string `json:"scheme"`
|
||||
Type string `json:"type"`
|
||||
Config string `json:"config"`
|
||||
Discovery eosc.RequireId `json:"discovery" skill:"github.com/eolinker/goku-eosc/discovery.discovery.IDiscovery"`
|
||||
Discovery eosc.RequireId `json:"discovery" skill:"github.com/eolinker/goku/discovery.discovery.IDiscovery"`
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package upstream_http
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
round_robin "github.com/eolinker/goku-eosc/upstream/round-robin"
|
||||
round_robin "github.com/eolinker/goku/upstream/round-robin"
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
)
|
||||
|
||||
@@ -6,20 +6,20 @@ import (
|
||||
|
||||
"github.com/valyala/fasthttp"
|
||||
|
||||
"github.com/eolinker/goku-eosc/upstream"
|
||||
"github.com/eolinker/goku/upstream"
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
|
||||
"github.com/eolinker/goku-eosc/service"
|
||||
"github.com/eolinker/goku/service"
|
||||
|
||||
"github.com/eolinker/goku-eosc/upstream/balance"
|
||||
"github.com/eolinker/goku/upstream/balance"
|
||||
|
||||
http_proxy "github.com/eolinker/goku-eosc/node/http-proxy"
|
||||
http_proxy "github.com/eolinker/goku/node/http-proxy"
|
||||
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
|
||||
"github.com/eolinker/goku-eosc/utils"
|
||||
"github.com/eolinker/goku/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -9,12 +9,12 @@ import (
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
|
||||
"github.com/eolinker/goku-eosc/discovery"
|
||||
"github.com/eolinker/goku/discovery"
|
||||
|
||||
"github.com/go-basic/uuid"
|
||||
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
"github.com/eolinker/goku-eosc/upstream"
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
"github.com/eolinker/goku/upstream"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -5,13 +5,13 @@ import (
|
||||
|
||||
"github.com/valyala/fasthttp"
|
||||
|
||||
"github.com/eolinker/goku-eosc/service"
|
||||
"github.com/eolinker/goku/service"
|
||||
|
||||
http_proxy "github.com/eolinker/goku-eosc/node/http-proxy"
|
||||
http_proxy "github.com/eolinker/goku/node/http-proxy"
|
||||
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
|
||||
"github.com/eolinker/goku-eosc/utils"
|
||||
"github.com/eolinker/goku/utils"
|
||||
)
|
||||
|
||||
func NewAnonymousUpstream() *httpUpstream {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package upstream
|
||||
|
||||
import (
|
||||
http_context "github.com/eolinker/goku-eosc/node/http-context"
|
||||
"github.com/eolinker/goku-eosc/service"
|
||||
http_context "github.com/eolinker/goku/node/http-context"
|
||||
"github.com/eolinker/goku/service"
|
||||
"github.com/valyala/fasthttp"
|
||||
)
|
||||
|
||||
//CheckSkill 检测目标技能是否符合
|
||||
func CheckSkill(skill string) bool {
|
||||
return skill == "github.com/eolinker/goku-eosc/upstream.upstream.IUpstream"
|
||||
return skill == "github.com/eolinker/goku/upstream.upstream.IUpstream"
|
||||
}
|
||||
|
||||
//IUpstream 实现了负载发送请求方法
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/eolinker/goku-eosc/auth"
|
||||
"github.com/eolinker/goku/auth"
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user