mirror of
https://github.com/eolinker/apinto
synced 2025-10-06 09:17:45 +08:00
Merge branch 'release/v0.8.2' into develop
# Conflicts: # build/resources/apinto.yml # build/resources/config.yml.tmp # drivers/app/app.go # drivers/app/manager/manager.go # drivers/discovery/consul/consul.go # drivers/discovery/eureka/eureka.go # drivers/discovery/nacos/nacos.go # drivers/plugins/app/app.go # drivers/router/http-router/http-handler.go # drivers/router/http-router/manager/manager.go # go.mod
This commit is contained in:
63
.github/workflows/actions.yaml
vendored
Normal file
63
.github/workflows/actions.yaml
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
name: packAndDockerImages
|
||||
#触发机制,当main分支有创建tag时
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
jobs:
|
||||
releasePackage:
|
||||
name: releaseOnGithub
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: SetOutput #处理Tag字符串并存进outputs
|
||||
id: vars
|
||||
run: |
|
||||
echo "tag=${GITHUB_REF#refs/*/v}" >> $GITHUB_OUTPUT
|
||||
- name: SetUpGo
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.17.3'
|
||||
- name: Checkout #Checkout代码
|
||||
uses: actions/checkout@v3
|
||||
- name: GoTidy
|
||||
run: go mod tidy
|
||||
- name: Create archives on Release #创建各种系统架构下的二进制包并上传至release assets
|
||||
uses: goreleaser/goreleaser-action@v3.1.0
|
||||
with:
|
||||
version: latest
|
||||
args: release --rm-dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
dockerImage:
|
||||
needs: [releasePackage]
|
||||
name: buildDockerImage
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: SetupGo
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.17.3'
|
||||
- uses: actions/checkout@v3
|
||||
- name: SetOutput
|
||||
id: vars
|
||||
run: echo "tag=${GITHUB_REF#refs/*/v}" >> $GITHUB_OUTPUT
|
||||
- name: GoTidy
|
||||
run: |
|
||||
go mod tidy
|
||||
- name: Pack #运行打包脚本并且将生成的tar包复制至Dockerfile所在目录
|
||||
run: |
|
||||
./build/cmd/package.sh ${{ steps.vars.outputs.tag }}
|
||||
cp ./out/apinto-${{ steps.vars.outputs.tag }}.linux.x64.tar.gz ./build/resources/apinto.linux.x64.tar.gz
|
||||
- name: Login Docker #登录docker
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_TOKEN }}
|
||||
- name: buildImage
|
||||
run: |
|
||||
docker build -t ${{ secrets.DOCKER_USERNAME }}/apinto-gateway:${{ steps.vars.outputs.tag }} -f ./build/resources/Dockerfile ./build/resources
|
||||
- name: pushImage
|
||||
run: |
|
||||
docker push ${{ secrets.DOCKER_USERNAME }}/apinto-gateway:${{ steps.vars.outputs.tag }}
|
||||
docker tag ${{ secrets.DOCKER_USERNAME }}/apinto-gateway:${{ steps.vars.outputs.tag }} ${{ secrets.DOCKER_USERNAME }}/apinto-gateway:latest
|
||||
docker push ${{ secrets.DOCKER_USERNAME }}/apinto-gateway:latest
|
41
.goreleaser.yaml
Normal file
41
.goreleaser.yaml
Normal file
@@ -0,0 +1,41 @@
|
||||
# .goreleaser.yml
|
||||
builds:
|
||||
- id: apinto
|
||||
goos:
|
||||
- linux
|
||||
- darwin
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
- "386"
|
||||
goarm:
|
||||
- "6"
|
||||
gomips:
|
||||
- hardfloat
|
||||
goamd64:
|
||||
- v1
|
||||
targets:
|
||||
- linux_arm64
|
||||
- linux_amd64
|
||||
- linux_386
|
||||
- darwin_arm64
|
||||
- darwin_amd64
|
||||
dir: ./app/apinto
|
||||
main: .
|
||||
binary: apinto
|
||||
builder: go
|
||||
gobinary: go
|
||||
ldflags:
|
||||
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser
|
||||
archives:
|
||||
- id: default
|
||||
format: tar.gz
|
||||
wrap_in_directory: apinto
|
||||
name_template: "{{ .ProjectName }}_{{ .Tag }}_{{ .Os }}_{{ .Arch }}"
|
||||
files:
|
||||
- src: 'build/resources/*'
|
||||
dst: /
|
||||
strip_parent: true
|
||||
release:
|
||||
name_template: "{{ .Tag }}"
|
||||
mode: append
|
23
README.md
23
README.md
@@ -9,6 +9,8 @@ Apinto is a microservice gateway developed based on golang. It can achieve the p
|
||||
|
||||
**Note**:The **main** branch is the main development branch. Frequent updates may lead to unstable use. If you need to use a stable version, please look [release](https://github.com/eolinker/apinto/releases)
|
||||
|
||||
**Apinto** integrates configuration and forwarding functions. Users can configure it through OpenAPI or through visual UI items [apinto dashboard](https://github.com/eolinker/apinto-dashboard) for configuration, click [apinto dashboard deployment document](https://help.apinto.com/docs/dashboard/quick/arrange) for relevant documents
|
||||
|
||||
### Summary / [中文介绍](https://github.com/eolinker/apinto/blob/main/README_CN.md)
|
||||
|
||||
- [Why Apinto](#WhyApinto "Why Apinto")
|
||||
@@ -33,7 +35,10 @@ Apinto API gateway has the following advantages:
|
||||
|
||||
In a word, Apinto API gateway enables the business development team to focus more on business implementation.
|
||||
|
||||
[](#)
|
||||
### Star History
|
||||
|
||||
[](https://star-history.com/#eolinker/apinto&Date)
|
||||
|
||||
|
||||
### Feture
|
||||
|
||||
@@ -80,18 +85,18 @@ In a word, Apinto API gateway enables the business development team to focus mor
|
||||
|
||||
### Deployment
|
||||
|
||||
* Direct Deployment:[Deployment Tutorial](https://help-apinto.eolink.com/?path=/quick/arrange)
|
||||
* [Quick Start Tutorial](https://help-apinto.eolink.com/?path=/quick/quick_course)
|
||||
* [Source Code Compilation Tutorial](https://help-apinto.eolink.com/?path=/quick/arrange)
|
||||
* Docker:Follow up support
|
||||
* Direct Deployment:[Deployment Tutorial](https://help.apinto.com/docs/apinto/quick/arrange.html)
|
||||
* [Quick Start Tutorial](https://help.apinto.com/docs/apinto/quick/quick_course.html)
|
||||
* [Source Code Compilation Tutorial](https://help.apinto.com/docs/apinto/quick/arrange.html)
|
||||
* [Docker](https://hub.docker.com/r/eolinker/apinto-gateway)
|
||||
* Kubernetes:Follow up support
|
||||
|
||||
### Get start
|
||||
|
||||
1. Download and unzip the installation package (here is an example of the installation package of version v0.5.1)
|
||||
1. Download and unzip the installation package (here is an example of the installation package of version v0.8.0)
|
||||
|
||||
```
|
||||
wget https://github.com/eolinker/apinto/releases/download/v0.5.1/apinto-v0.5.1.linux.x64.tar.gz && tar -zxvf apinto-v0.5.1.linux.x64.tar.gz && cd apinto
|
||||
wget https://github.com/eolinker/apinto/releases/download/v0.8.0/apinto-v0.8.0.linux.x64.tar.gz && tar -zxvf apinto-v0.8.0.linux.x64.tar.gz && cd apinto
|
||||
```
|
||||
|
||||
2. Start gateway:
|
||||
@@ -100,8 +105,10 @@ wget https://github.com/eolinker/apinto/releases/download/v0.5.1/apinto-v0.5.1.l
|
||||
./apinto start
|
||||
```
|
||||
|
||||
3.To configure the gateway through the visual interface, click [apinto dashboard](https://github.com/eolinker/apinto-dashboard)
|
||||
|
||||
### Contact
|
||||
- **Help documentation**:[https://help.apinto.com](https://help.apinto.com)
|
||||
- **Help documentation**:[https://help.apinto.com](https://help.apinto.com/docs)
|
||||
- **QQ group**: 725853895
|
||||
- **Slack**:[Join us](https://join.slack.com/t/slack-zer6755/shared_invite/zt-u7wzqp1u-aNA0XK9Bdb3kOpN03jRmYQ)
|
||||
- **Official website**:[https://www.apinto.com](https://www.apinto.com)
|
||||
|
23
README_CN.md
23
README_CN.md
@@ -11,6 +11,7 @@ Apinto是一个基于 Golang 开发的微服务网关,能够实现高性能 HT
|
||||
|
||||
注意:**main**分支为开发主要分支,频繁更新可能导致使用不稳定,若需要使用稳定版本,请查看[release](https://github.com/eolinker/apinto/releases)
|
||||
|
||||
**Apinto** 集合了配置和转发功能,使用者可以通过openAPI进行配置,也可通过可视化UI项目[Apinto Dashboard](https://github.com/eolinker/apinto-dashboard)进行配置,相关文档可点击[Apinto Dashboard部署文档](https://help.apinto.com/docs/dashboard/quick/arrange)
|
||||
### 概况 | [English Introduction](https://github.com/eolinker/apinto/blob/main/README.md)
|
||||
|
||||
- [为什么要使用Apinto](#为什么要使用Apinto "Apinto")
|
||||
@@ -36,7 +37,10 @@ Apinto是一个基于 Golang 开发的微服务网关,能够实现高性能 HT
|
||||
|
||||
总而言之,Apinto 能让业务开发团队更加专注地实现业务。
|
||||
|
||||
[](#)
|
||||
### Star 历史
|
||||
|
||||
[](https://star-history.com/#eolinker/apinto&Date)
|
||||
|
||||
|
||||
### 产品特性
|
||||
|
||||
@@ -84,18 +88,18 @@ Apinto是一个基于 Golang 开发的微服务网关,能够实现高性能 HT
|
||||
|
||||
### 部署
|
||||
|
||||
* 直接部署:[部署教程](https://help.apinto.com/?path=/quick/arrange)
|
||||
* [快速入门教程](https://help.apinto.com/?path=/quick/quick_course)
|
||||
* [源码编译教程](https://help.apinto.com/?path=/quick/arrange)
|
||||
* Docker部署:后续支持
|
||||
* 直接部署:[部署教程](https://help.apinto.com/docs/apinto/quick/arrange)
|
||||
* [快速入门教程](https://help.apinto.com/docs/apinto/quick/quick_course)
|
||||
* [源码编译教程](https://help.apinto.com/docs/apinto/quick/arrange)
|
||||
* [Docker部署](https://hub.docker.com/r/eolinker/apinto-gateway)
|
||||
* Kubernetes部署:后续支持
|
||||
|
||||
### 启动
|
||||
|
||||
1.下载安装包并解压(此处以v0.5.1版本的安装包示例)
|
||||
1.下载安装包并解压(此处以v0.8.0版本的安装包示例)
|
||||
|
||||
```
|
||||
wget https://github.com/eolinker/apinto/releases/download/v0.5.1/apinto-v0.5.1.linux.x64.tar.gz && tar -zxvf apinto-v0.5.1.linux.x64.tar.gz && cd apinto
|
||||
wget https://github.com/eolinker/apinto/releases/download/v0.8.0/apinto-v0.8.0.linux.x64.tar.gz && tar -zxvf apinto-v0.8.0.linux.x64.tar.gz && cd apinto
|
||||
```
|
||||
|
||||
2.启动网关:
|
||||
@@ -104,10 +108,13 @@ wget https://github.com/eolinker/apinto/releases/download/v0.5.1/apinto-v0.5.1.l
|
||||
./apinto start
|
||||
```
|
||||
|
||||
3.如需可视化界面请点击[Apinto Dashboard](https://github.com/eolinker/apinto-dashboard)
|
||||
|
||||
|
||||
- ### **联系我们**
|
||||
|
||||
|
||||
* **帮助文档**:[https://help.apinto.com](https://help.apinto.com/)
|
||||
* **帮助文档**:[https://help.apinto.com](https://help.apinto.com/docs)
|
||||
|
||||
- **QQ群**: 725853895
|
||||
|
||||
|
1
app/apinto/.gitignore
vendored
1
app/apinto/.gitignore
vendored
@@ -6,3 +6,4 @@ apinto*
|
||||
/apinto
|
||||
/tmp/
|
||||
/tmp_bak/
|
||||
/logs/
|
||||
|
@@ -24,7 +24,6 @@ func init() {
|
||||
|
||||
type IApp interface {
|
||||
Id() string
|
||||
Name() string
|
||||
Labels() map[string]string
|
||||
Disable() bool
|
||||
IAppExecutor
|
||||
|
29
build/resources/apinto.yml
Normal file
29
build/resources/apinto.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
# 数据文件放置目录
|
||||
# data_dir: /var/lib/apinto
|
||||
|
||||
# pid文件放置地址
|
||||
# pid_dir: /var/run/apinto/
|
||||
|
||||
# 日志放置目录
|
||||
# log_dir: /var/log/apinto
|
||||
|
||||
# socket放置目录
|
||||
# socket_dir: /tmp/apinto
|
||||
|
||||
# apinto运行配置地址
|
||||
# config: /etc/apinto/config.yml
|
||||
|
||||
# 扩展仓库目录
|
||||
# extends_dir: /var/lib/apinto/extenders/
|
||||
|
||||
# 错误日志文件名
|
||||
# error_log_name: error.log
|
||||
|
||||
# 错误日志等级
|
||||
# error_log_level: error
|
||||
|
||||
# 错误日志过期时间,默认单位为天,d|天,h|小时
|
||||
# error_log_expire: 7d
|
||||
|
||||
# 错误日志切割周期,仅支持day、hour
|
||||
# error_log_period: day
|
7
build/resources/config.yml.tmp
Normal file
7
build/resources/config.yml.tmp
Normal file
@@ -0,0 +1,7 @@
|
||||
listen: # node listen port
|
||||
- 8099
|
||||
|
||||
admin: # openAPI request info
|
||||
scheme: http # listen scheme
|
||||
listen: 9400 # listen port
|
||||
ip: 0.0.0.0 # listen ip
|
@@ -33,6 +33,9 @@ func checkConfig(v interface{}) (*Config, error) {
|
||||
if conf.Anonymous && len(conf.Auth) > 0 {
|
||||
return nil, errors.New("it is anonymous app,auths should be empty")
|
||||
}
|
||||
if conf.Anonymous && len(conf.Auth) > 0 {
|
||||
return nil, errors.New("it is anonymous app,auths should be empty")
|
||||
}
|
||||
for _, a := range conf.Auth {
|
||||
err := application.CheckPosition(a.Position)
|
||||
if err != nil {
|
||||
|
@@ -25,7 +25,7 @@ type consul struct {
|
||||
cancelFunc context.CancelFunc
|
||||
}
|
||||
|
||||
//Start 开始服务发现
|
||||
// Start 开始服务发现
|
||||
func (c *consul) Start() error {
|
||||
ctx, cancelFunc := context.WithCancel(context.Background())
|
||||
c.context = ctx
|
||||
@@ -65,7 +65,7 @@ func (c *consul) Start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//Reset 重置consul实例配置
|
||||
// Reset 重置consul实例配置
|
||||
func (c *consul) Reset(cfg interface{}, workers map[eosc.RequireId]eosc.IWorker) error {
|
||||
workerConfig, ok := cfg.(*Config)
|
||||
if !ok {
|
||||
@@ -78,13 +78,13 @@ func (c *consul) Reset(cfg interface{}, workers map[eosc.RequireId]eosc.IWorker)
|
||||
return nil
|
||||
}
|
||||
|
||||
//Stop 停止服务发现
|
||||
// Stop 停止服务发现
|
||||
func (c *consul) Stop() error {
|
||||
c.cancelFunc()
|
||||
return nil
|
||||
}
|
||||
|
||||
//Remove 从所有服务app中移除目标app
|
||||
// Remove 从所有服务app中移除目标app
|
||||
func (c *consul) Remove(id string) error {
|
||||
c.locker.Lock()
|
||||
defer c.locker.Unlock()
|
||||
@@ -95,7 +95,7 @@ func (c *consul) Remove(id string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//GetApp 获取服务发现中目标服务的app
|
||||
// GetApp 获取服务发现中目标服务的app
|
||||
func (c *consul) GetApp(serviceName string) (discovery.IApp, error) {
|
||||
var err error
|
||||
var has bool
|
||||
@@ -108,8 +108,8 @@ func (c *consul) GetApp(serviceName string) (discovery.IApp, error) {
|
||||
if !has {
|
||||
nodes, err = c.clients.getNodes(serviceName)
|
||||
if err != nil {
|
||||
c.locker.Unlock()
|
||||
return nil, err
|
||||
log.Errorf("%s get %s node list error: %v", driverName, serviceName, err)
|
||||
nodes = make(discovery.Nodes)
|
||||
}
|
||||
|
||||
c.nodes.Set(serviceName, nodes)
|
||||
@@ -126,7 +126,7 @@ func (c *consul) GetApp(serviceName string) (discovery.IApp, error) {
|
||||
return app, nil
|
||||
}
|
||||
|
||||
//Create 创建目标服务的app
|
||||
// Create 创建目标服务的app
|
||||
func (c *consul) Create(serviceName string, attrs map[string]string, nodes map[string]discovery.INode) (discovery.IApp, error) {
|
||||
return discovery.NewApp(nil, c, attrs, nodes), nil
|
||||
}
|
||||
|
@@ -8,6 +8,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/eolinker/eosc/utils/config"
|
||||
|
||||
"github.com/eolinker/eosc/log"
|
||||
|
||||
"github.com/eolinker/apinto/discovery"
|
||||
@@ -24,7 +26,7 @@ type eureka struct {
|
||||
locker sync.RWMutex
|
||||
}
|
||||
|
||||
//GetApp 获取服务发现中目标服务的app
|
||||
// GetApp 获取服务发现中目标服务的app
|
||||
func (e *eureka) GetApp(serviceName string) (discovery.IApp, error) {
|
||||
e.locker.RLock()
|
||||
nodes, ok := e.nodes.Get(serviceName)
|
||||
@@ -36,8 +38,8 @@ func (e *eureka) GetApp(serviceName string) (discovery.IApp, error) {
|
||||
// 开始重新获取
|
||||
ns, err := e.client.GetNodeList(serviceName)
|
||||
if err != nil {
|
||||
e.locker.Unlock()
|
||||
return nil, err
|
||||
log.Errorf("%s get %s node list error: %v", driverName, serviceName, err)
|
||||
ns = make(discovery.Nodes)
|
||||
}
|
||||
e.nodes.Set(serviceName, ns)
|
||||
nodes = ns
|
||||
@@ -50,7 +52,7 @@ func (e *eureka) GetApp(serviceName string) (discovery.IApp, error) {
|
||||
return app, nil
|
||||
}
|
||||
|
||||
//Remove 从所有服务app中移除目标app
|
||||
// Remove 从所有服务app中移除目标app
|
||||
func (e *eureka) Remove(id string) error {
|
||||
e.locker.Lock()
|
||||
defer e.locker.Unlock()
|
||||
@@ -99,7 +101,7 @@ func (e *eureka) Start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//Reset 重置eureka实例配置
|
||||
// Reset 重置eureka实例配置
|
||||
func (e *eureka) Reset(conf interface{}, workers map[eosc.RequireId]eosc.IWorker) error {
|
||||
cfg, ok := conf.(*Config)
|
||||
if !ok {
|
||||
@@ -109,13 +111,13 @@ func (e *eureka) Reset(conf interface{}, workers map[eosc.RequireId]eosc.IWorker
|
||||
return nil
|
||||
}
|
||||
|
||||
//Stop 停止服务发现
|
||||
// Stop 停止服务发现
|
||||
func (e *eureka) Stop() error {
|
||||
e.cancelFunc()
|
||||
return nil
|
||||
}
|
||||
|
||||
//CheckSkill 检查目标能力是否存在
|
||||
// CheckSkill 检查目标能力是否存在
|
||||
func (e *eureka) CheckSkill(skill string) bool {
|
||||
return discovery.CheckSkill(skill)
|
||||
}
|
||||
|
@@ -8,6 +8,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/eolinker/eosc/utils/config"
|
||||
|
||||
"github.com/eolinker/eosc/log"
|
||||
|
||||
"github.com/eolinker/apinto/discovery"
|
||||
@@ -28,7 +30,7 @@ type nacos struct {
|
||||
locker sync.RWMutex
|
||||
}
|
||||
|
||||
//Instance nacos 服务实例结构
|
||||
// Instance nacos 服务实例结构
|
||||
type Instance struct {
|
||||
Hosts []struct {
|
||||
Valid bool `json:"valid"`
|
||||
@@ -45,7 +47,7 @@ func (n *nacos) CheckSkill(skill string) bool {
|
||||
return discovery.CheckSkill(skill)
|
||||
}
|
||||
|
||||
//Start 开始服务发现
|
||||
// Start 开始服务发现
|
||||
func (n *nacos) Start() error {
|
||||
ctx, cancelFunc := context.WithCancel(context.Background())
|
||||
n.context = ctx
|
||||
@@ -83,7 +85,7 @@ func (n *nacos) Start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//Reset 重置nacos实例配置
|
||||
// Reset 重置nacos实例配置
|
||||
func (n *nacos) Reset(conf interface{}, workers map[eosc.RequireId]eosc.IWorker) error {
|
||||
cfg, ok := conf.(*Config)
|
||||
if !ok {
|
||||
@@ -93,13 +95,13 @@ func (n *nacos) Reset(conf interface{}, workers map[eosc.RequireId]eosc.IWorker)
|
||||
return nil
|
||||
}
|
||||
|
||||
//Stop 停止服务发现
|
||||
// Stop 停止服务发现
|
||||
func (n *nacos) Stop() error {
|
||||
n.cancelFunc()
|
||||
return nil
|
||||
}
|
||||
|
||||
//Remove 从所有服务app中移除目标app
|
||||
// Remove 从所有服务app中移除目标app
|
||||
func (n *nacos) Remove(id string) error {
|
||||
n.locker.Lock()
|
||||
defer n.locker.Unlock()
|
||||
@@ -110,7 +112,7 @@ func (n *nacos) Remove(id string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//GetApp 获取服务发现中目标服务的app
|
||||
// GetApp 获取服务发现中目标服务的app
|
||||
func (n *nacos) GetApp(serviceName string) (discovery.IApp, error) {
|
||||
n.locker.RLock()
|
||||
nodes, ok := n.nodes.Get(serviceName)
|
||||
@@ -121,8 +123,8 @@ func (n *nacos) GetApp(serviceName string) (discovery.IApp, error) {
|
||||
if !ok {
|
||||
ns, err := n.client.GetNodeList(serviceName)
|
||||
if err != nil {
|
||||
n.locker.Unlock()
|
||||
return nil, err
|
||||
log.Errorf("%s get %s node list error: %v", driverName, serviceName, err)
|
||||
ns = make(discovery.Nodes)
|
||||
}
|
||||
|
||||
n.nodes.Set(serviceName, ns)
|
||||
|
@@ -60,14 +60,14 @@ func (a *App) DoWebsocketFilter(ctx http_service.IWebsocketContext, next eoconte
|
||||
}
|
||||
|
||||
func (a *App) auth(ctx http_service.IHttpContext) error {
|
||||
driver := ctx.Request().Header().GetHeader("Authorization-Type")
|
||||
filters := appManager.ListByDriver(driver)
|
||||
if len(filters) < 1 {
|
||||
if appManager.Count() > 0 {
|
||||
filters = appManager.List()
|
||||
} else {
|
||||
if appManager.Count() < 1 {
|
||||
return nil
|
||||
}
|
||||
driver := ctx.Request().Header().GetHeader("Authorization-Type")
|
||||
filters := appManager.ListByDriver(driver)
|
||||
|
||||
if len(filters) < 1 {
|
||||
filters = appManager.List()
|
||||
}
|
||||
for _, filter := range filters {
|
||||
user, ok := filter.GetUser(ctx)
|
||||
|
@@ -3,11 +3,12 @@ package http_complete
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/eolinker/eosc/eocontext"
|
||||
http_service "github.com/eolinker/eosc/eocontext/http-context"
|
||||
"github.com/eolinker/eosc/log"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -60,8 +61,9 @@ func (h *HttpComplete) Complete(org eocontext.EoContext) error {
|
||||
}
|
||||
node, err := balance.Select(ctx)
|
||||
if err != nil {
|
||||
log.Error("select error: ", lastErr)
|
||||
|
||||
log.Error("select error: ", err)
|
||||
ctx.Response().SetStatus(501, "501")
|
||||
ctx.Response().SetBody([]byte(err.Error()))
|
||||
return err
|
||||
}
|
||||
|
||||
|
@@ -62,5 +62,4 @@ func (h *httpHandler) ServeHTTP(ctx eocontext.EoContext) {
|
||||
ctx.SetUpstreamHostHandler(h.service)
|
||||
|
||||
h.filters.Chain(ctx, completeCaller)
|
||||
ctx.GetFinish().Finish(ctx)
|
||||
}
|
||||
|
@@ -122,8 +122,10 @@ func (m *Manager) FastHandler(port int, ctx *fasthttp.RequestCtx) {
|
||||
log.Debug("match has:", port)
|
||||
r.ServeHTTP(httpContext)
|
||||
}
|
||||
//}
|
||||
httpContext.GetFinish().Finish(httpContext)
|
||||
}
|
||||
|
||||
type NotFoundHandler struct {
|
||||
}
|
||||
|
||||
type HttpNotFoundHandler struct {
|
||||
|
Reference in New Issue
Block a user