1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-11-24 08:02:32 +02:00

[feat] dashboard update (#2381)

* [feature] dashboard update
This commit is contained in:
Johnson C 2021-12-07 10:42:31 +08:00 committed by GitHub
parent 97f169c424
commit b00c8368b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 81 additions and 245 deletions

View File

@ -4,7 +4,7 @@ import "time"
const (
Name = "go.micro.dashboard"
Version = "1.1.0"
Version = "1.2.0"
)
type Config struct {

View File

@ -3,25 +3,25 @@ module github.com/asim/go-micro/cmd/dashboard/v4
go 1.17
require (
github.com/asim/go-micro/plugins/broker/kafka/v4 v4.0.0-20211124174154-b25d744f5c51
github.com/asim/go-micro/plugins/broker/kafka/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/asim/go-micro/plugins/broker/mqtt/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/asim/go-micro/plugins/broker/nats/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/asim/go-micro/plugins/broker/rabbitmq/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/asim/go-micro/plugins/broker/redis/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/asim/go-micro/plugins/client/grpc/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/asim/go-micro/plugins/client/grpc/v4 v4.0.0-20211202051538-c0e0b2b22508
github.com/asim/go-micro/plugins/client/http/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/asim/go-micro/plugins/client/mucp/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/asim/go-micro/plugins/config/encoder/toml/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/asim/go-micro/plugins/config/encoder/yaml/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/asim/go-micro/plugins/registry/consul/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/asim/go-micro/plugins/registry/etcd/v4 v4.0.0-20211124174154-b25d744f5c51
github.com/asim/go-micro/plugins/registry/etcd/v4 v4.0.0-20211202051538-c0e0b2b22508
github.com/asim/go-micro/plugins/registry/eureka/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/asim/go-micro/plugins/registry/gossip/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/asim/go-micro/plugins/registry/kubernetes/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/asim/go-micro/plugins/registry/kubernetes/v4 v4.0.0-20211205115617-97f169c424fe
github.com/asim/go-micro/plugins/registry/nacos/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/asim/go-micro/plugins/registry/nats/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/asim/go-micro/plugins/registry/zookeeper/v4 v4.0.0-20211124174154-b25d744f5c51
github.com/asim/go-micro/plugins/server/http/v4 v4.0.0-20211124174154-b25d744f5c51
github.com/asim/go-micro/plugins/registry/zookeeper/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/asim/go-micro/plugins/server/http/v4 v4.0.0-20211201082631-1e4dd94b71f1
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/gin-gonic/gin v1.7.7
github.com/pkg/errors v0.9.1

View File

@ -82,8 +82,8 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/asim/go-micro/plugins/broker/kafka/v4 v4.0.0-20211124174154-b25d744f5c51 h1:M6PKj4Rwy0fVmrI53KqAiw60gGMI3Js1faSeI4uRgAI=
github.com/asim/go-micro/plugins/broker/kafka/v4 v4.0.0-20211124174154-b25d744f5c51/go.mod h1:Lagmt4bIzAq6APlwpTQxUbh+1xfqgYS8Qeja8w3boV8=
github.com/asim/go-micro/plugins/broker/kafka/v4 v4.0.0-20211201082631-1e4dd94b71f1 h1:lDTDRppOUIGywiOwEXjimjHm4fjz/GX9PAvsxIBC9JE=
github.com/asim/go-micro/plugins/broker/kafka/v4 v4.0.0-20211201082631-1e4dd94b71f1/go.mod h1:Lagmt4bIzAq6APlwpTQxUbh+1xfqgYS8Qeja8w3boV8=
github.com/asim/go-micro/plugins/broker/mqtt/v4 v4.0.0-20211201082631-1e4dd94b71f1 h1:rGrxmHP4I/hXWiaOJJSjOnhnIYJ6OQANDVCCbj1wVq8=
github.com/asim/go-micro/plugins/broker/mqtt/v4 v4.0.0-20211201082631-1e4dd94b71f1/go.mod h1:IuTGyj/A67ywbJG2jIPeaHZOmimjKq/xQqOeUo5bEE0=
github.com/asim/go-micro/plugins/broker/nats/v4 v4.0.0-20211201082631-1e4dd94b71f1 h1:vk2vwh6GozuMTR4xANf4NWOhzHEmjJ8AKDHgCau1cic=
@ -92,8 +92,8 @@ github.com/asim/go-micro/plugins/broker/rabbitmq/v4 v4.0.0-20211201082631-1e4dd9
github.com/asim/go-micro/plugins/broker/rabbitmq/v4 v4.0.0-20211201082631-1e4dd94b71f1/go.mod h1:B/znrfbAKqPhVBDmKpwoIb8qx2Lhrww/1yL1rcE0Kik=
github.com/asim/go-micro/plugins/broker/redis/v4 v4.0.0-20211201082631-1e4dd94b71f1 h1:Yhn5PixugZVFVyfX5TxP9vLJRG1Hj6LbVBCC5jO9xBA=
github.com/asim/go-micro/plugins/broker/redis/v4 v4.0.0-20211201082631-1e4dd94b71f1/go.mod h1://EU7a+nW+5ZCseQkg90XXQI1ZwPSLF49IdUUIM5PM0=
github.com/asim/go-micro/plugins/client/grpc/v4 v4.0.0-20211201082631-1e4dd94b71f1 h1:GCEFKXorNsDzKKOWXueuYJipG8l++4fAogY+wpTrduc=
github.com/asim/go-micro/plugins/client/grpc/v4 v4.0.0-20211201082631-1e4dd94b71f1/go.mod h1:P/Jjf1gCQqBAgpVerr3opyTU594ns1t0JZXsDAYh86c=
github.com/asim/go-micro/plugins/client/grpc/v4 v4.0.0-20211202051538-c0e0b2b22508 h1:pNTBB/yP3hIVMwQpTkcZyv5P0SmskHunzIHd4VE25M4=
github.com/asim/go-micro/plugins/client/grpc/v4 v4.0.0-20211202051538-c0e0b2b22508/go.mod h1:P/Jjf1gCQqBAgpVerr3opyTU594ns1t0JZXsDAYh86c=
github.com/asim/go-micro/plugins/client/http/v4 v4.0.0-20211201082631-1e4dd94b71f1 h1:jx7TbrIapl+HOkmQKQQVZ10eDw1fxRhJg7ohIqEed+w=
github.com/asim/go-micro/plugins/client/http/v4 v4.0.0-20211201082631-1e4dd94b71f1/go.mod h1:b6uXG9QOlAs3Eh1es67Y6Mq6ALHyoQT+t0tFZEWW8+8=
github.com/asim/go-micro/plugins/client/mucp/v4 v4.0.0-20211201082631-1e4dd94b71f1 h1:I8bfcO2hD3g9sLkxET2c2PgMzPgN3U3HtgqFWtsYOBY=
@ -104,22 +104,22 @@ github.com/asim/go-micro/plugins/config/encoder/yaml/v4 v4.0.0-20211201082631-1e
github.com/asim/go-micro/plugins/config/encoder/yaml/v4 v4.0.0-20211201082631-1e4dd94b71f1/go.mod h1:tRcpGjk28FtJQyp4DtmCMdEIyr/wDkCmtVQtv8dx4t0=
github.com/asim/go-micro/plugins/registry/consul/v4 v4.0.0-20211201082631-1e4dd94b71f1 h1:P1flbbRCOp7WiY2benDCzpplZ2aRN7BtY08tcpLZiLc=
github.com/asim/go-micro/plugins/registry/consul/v4 v4.0.0-20211201082631-1e4dd94b71f1/go.mod h1:cCagHmMVGVea+8gzr0AC+yXtwtCIB6iXh20ipF9coOA=
github.com/asim/go-micro/plugins/registry/etcd/v4 v4.0.0-20211124174154-b25d744f5c51 h1:gXD6unb70+lX6X2qWq4EG/3tM0tTx7HZMrf5925RRU8=
github.com/asim/go-micro/plugins/registry/etcd/v4 v4.0.0-20211124174154-b25d744f5c51/go.mod h1:maR33ztnKc7VeMioGfl1vq3Jm7fzztbNoRWTncu96sc=
github.com/asim/go-micro/plugins/registry/etcd/v4 v4.0.0-20211202051538-c0e0b2b22508 h1:Y6HWP3F+eF0Kv9NK2CbOCI+oKouqyBg2DaWzo0/Ld+U=
github.com/asim/go-micro/plugins/registry/etcd/v4 v4.0.0-20211202051538-c0e0b2b22508/go.mod h1:maR33ztnKc7VeMioGfl1vq3Jm7fzztbNoRWTncu96sc=
github.com/asim/go-micro/plugins/registry/eureka/v4 v4.0.0-20211201082631-1e4dd94b71f1 h1:EOiQJYDtT/yEsnPyUmj893Mhu3iL++Yo3uN8JNyWnZA=
github.com/asim/go-micro/plugins/registry/eureka/v4 v4.0.0-20211201082631-1e4dd94b71f1/go.mod h1:CrbuvEFuiWZd+BCrvSFF35BTYsUAPMrvNIhGb7UdPI4=
github.com/asim/go-micro/plugins/registry/gossip/v4 v4.0.0-20211201082631-1e4dd94b71f1 h1:tKiOojNZOZPC4G0mJHDIknlDUWYHmfyTBgOF45suK6Y=
github.com/asim/go-micro/plugins/registry/gossip/v4 v4.0.0-20211201082631-1e4dd94b71f1/go.mod h1:6rLyGiwvfYh60RSHnV8rQgw2nA01oj8UMSmYP+j2eps=
github.com/asim/go-micro/plugins/registry/kubernetes/v4 v4.0.0-20211201082631-1e4dd94b71f1 h1:fnEH9/B648yYVioy4aoI1nl+Z/KSFf6+opwHvwsBh08=
github.com/asim/go-micro/plugins/registry/kubernetes/v4 v4.0.0-20211201082631-1e4dd94b71f1/go.mod h1:oSNX75DUoUh/Fn3LABL5Ukf2OwjSBTrTm8pFsHeFfw8=
github.com/asim/go-micro/plugins/registry/kubernetes/v4 v4.0.0-20211205115617-97f169c424fe h1:OzrZ7VGQCjvHSvcov33//ddZO2AcPmj6IHcvZtDi8sQ=
github.com/asim/go-micro/plugins/registry/kubernetes/v4 v4.0.0-20211205115617-97f169c424fe/go.mod h1:oSNX75DUoUh/Fn3LABL5Ukf2OwjSBTrTm8pFsHeFfw8=
github.com/asim/go-micro/plugins/registry/nacos/v4 v4.0.0-20211201082631-1e4dd94b71f1 h1:qAJ8wIcxh7TvaQcWecGPvb7xpn17n7gRFQb67eU0p3U=
github.com/asim/go-micro/plugins/registry/nacos/v4 v4.0.0-20211201082631-1e4dd94b71f1/go.mod h1:E6DSmDRtS7He6PkfnWGNj4y8fCr6XYlftsbOlI3ZNqk=
github.com/asim/go-micro/plugins/registry/nats/v4 v4.0.0-20211201082631-1e4dd94b71f1 h1:pJkFhfu+bWTfOfdJ4PG47xHEXPWiCNkE57XyfPJM5Q4=
github.com/asim/go-micro/plugins/registry/nats/v4 v4.0.0-20211201082631-1e4dd94b71f1/go.mod h1:n4K0361IySJ/hmIfaIg8q2NDNAVDL9DUC6Bh7gS4ihg=
github.com/asim/go-micro/plugins/registry/zookeeper/v4 v4.0.0-20211124174154-b25d744f5c51 h1:6eqdlnrL/0y9C9j9TvNztaUchuhB0BeYrzqowHDSsHM=
github.com/asim/go-micro/plugins/registry/zookeeper/v4 v4.0.0-20211124174154-b25d744f5c51/go.mod h1:1u6V7M1VOgFGkXafSPUGhBVf6W3l0Zl+5pdsVztkdzA=
github.com/asim/go-micro/plugins/server/http/v4 v4.0.0-20211124174154-b25d744f5c51 h1:wYFQxeAjrCWA6hxR2qw72iMaNxU8BqNf65JfgMOC0NA=
github.com/asim/go-micro/plugins/server/http/v4 v4.0.0-20211124174154-b25d744f5c51/go.mod h1:LEsuhy4ZF3UGT9VSOoj/ZP0MZt4brlgwJVG7/LAac+I=
github.com/asim/go-micro/plugins/registry/zookeeper/v4 v4.0.0-20211201082631-1e4dd94b71f1 h1:FxOQObNFv0iF013P2SY86qlMXlLUxHmcgdmSbAwrMEc=
github.com/asim/go-micro/plugins/registry/zookeeper/v4 v4.0.0-20211201082631-1e4dd94b71f1/go.mod h1:yK6eYLe+OdFjo1tx0AQ17+0frvG6C+nLnFMiGt9uMU0=
github.com/asim/go-micro/plugins/server/http/v4 v4.0.0-20211201082631-1e4dd94b71f1 h1:DMeGq8oDvWICSbMlQaYab81E5W53RRQ3lvIiWp/2rLM=
github.com/asim/go-micro/plugins/server/http/v4 v4.0.0-20211201082631-1e4dd94b71f1/go.mod h1:LEsuhy4ZF3UGT9VSOoj/ZP0MZt4brlgwJVG7/LAac+I=
github.com/aws/aws-sdk-go v1.37.27/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=

View File

@ -31,7 +31,7 @@ func Register(opts Options) error {
registry.NewRouteRegistrar(opts.Client.Options().Registry),
statistics.NewRouteRegistrar(opts.Client.Options().Registry),
} {
r.RegisterRoute(router)
r.RegisterRoute(router.Group(""))
}
return nil
}

View File

@ -1,51 +0,0 @@
package handler
import (
"net/http"
"strings"
"github.com/asim/go-micro/cmd/dashboard/v4/config"
"github.com/dgrijalva/jwt-go"
"github.com/gin-gonic/gin"
)
func AuthRequired() gin.HandlerFunc {
return func(ctx *gin.Context) {
if ctx.Request.Method == "OPTIONS" {
ctx.Next()
return
}
tokenString := ctx.GetHeader("Authorization")
if len(tokenString) == 0 || !strings.HasPrefix(tokenString, "Bearer ") {
ctx.AbortWithStatusJSON(http.StatusUnauthorized, "")
return
}
tokenString = tokenString[7:]
claims := jwt.StandardClaims{}
token, err := jwt.ParseWithClaims(tokenString, &claims, func(t *jwt.Token) (interface{}, error) {
return []byte(config.GetAuthConfig().TokenSecret), nil
})
if err != nil {
ctx.AbortWithError(http.StatusUnauthorized, err)
}
if !token.Valid {
ctx.AbortWithStatus(http.StatusUnauthorized)
}
ctx.Set("username", claims.Subject)
ctx.Next()
}
}
func CorsHandler(allowOrigin string) gin.HandlerFunc {
return func(ctx *gin.Context) {
ctx.Header("Access-Control-Allow-Origin", allowOrigin)
ctx.Header("Access-Control-Allow-Headers", "Content-Type, Authorization, token")
ctx.Header("Access-Control-Allow-Methods", "POST, GET, DELETE, PUT, OPTIONS")
ctx.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type")
ctx.Header("Access-Control-Allow-Credentials", "true")
if ctx.Request.Method == "OPTIONS" {
ctx.AbortWithStatus(http.StatusNoContent)
}
ctx.Next()
}
}

View File

@ -1,5 +1,5 @@
// Code generated by fileb0x at "2021-12-02 10:03:04.6115997 +0800 CST m=+0.057062001" from config file "b0x.yaml" DO NOT EDIT.
// modification hash(c71255f8c39564687acdced2f2c06267.8be3f833d63e3c844663716446e13a42)
// Code generated by fileb0x at "2021-12-07 10:11:10.4808383 +0800 CST m=+0.057013201" from config file "b0x.yaml" DO NOT EDIT.
// modification hash(fecae112933101acf070cd0740e400a2.8be3f833d63e3c844663716446e13a42)
package web

View File

@ -1,5 +1,5 @@
// Code generaTed by fileb0x at "2021-12-02 10:03:04.6170147 +0800 CST m=+0.062477001" from config file "b0x.yaml" DO NOT EDIT.
// modified(2021-12-02 09:58:47.9180366 +0800 CST)
// Code generaTed by fileb0x at "2021-12-07 10:11:10.6402683 +0800 CST m=+0.216443201" from config file "b0x.yaml" DO NOT EDIT.
// modified(2021-12-07 10:11:05.7530359 +0800 CST)
// original path: frontend\dist\449.ea3505f8c3a78bc5ec51.js
package web

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
// Code generaTed by fileb0x at "2021-12-02 10:03:04.7626995 +0800 CST m=+0.208161801" from config file "b0x.yaml" DO NOT EDIT.
// modified(2021-12-02 09:58:47.9180366 +0800 CST)
// Code generaTed by fileb0x at "2021-12-07 10:11:10.6541906 +0800 CST m=+0.230365501" from config file "b0x.yaml" DO NOT EDIT.
// modified(2021-12-07 10:11:05.7530359 +0800 CST)
// original path: frontend\dist\polyfills.d3127c390f57a23419e1.js
package web

View File

@ -1,5 +1,5 @@
// Code generaTed by fileb0x at "2021-12-02 10:03:04.7764137 +0800 CST m=+0.221876001" from config file "b0x.yaml" DO NOT EDIT.
// modified(2021-12-02 09:58:47.9180366 +0800 CST)
// Code generaTed by fileb0x at "2021-12-07 10:11:10.5996812 +0800 CST m=+0.175856101" from config file "b0x.yaml" DO NOT EDIT.
// modified(2021-12-07 10:11:05.7530359 +0800 CST)
// original path: frontend\dist\runtime.0edec77bcc0e6f764d02.js
package web

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
// Code generaTed by fileb0x at "2021-12-02 10:03:04.7788 +0800 CST m=+0.224262301" from config file "b0x.yaml" DO NOT EDIT.
// modified(2021-12-02 09:58:47.9190359 +0800 CST)
// Code generaTed by fileb0x at "2021-12-07 10:11:10.6017344 +0800 CST m=+0.177909301" from config file "b0x.yaml" DO NOT EDIT.
// modified(2021-12-07 10:11:05.7530359 +0800 CST)
// original path: frontend\dist\styles.40a72a43f1959e5b9ccc.css
package web

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,8 @@
package web
import (
"os"
"os/exec"
"path/filepath"
"github.com/gin-gonic/gin"
@ -25,10 +27,15 @@ func RegisterRoute(router *gin.Engine) error {
case ".css":
c.Header("Content-Type", "text/css; charset=utf-8")
case ".js":
c.Header("Content-Type", "application/javascript")
c.Header("Content-Type", "text/javascript")
case ".svg":
c.Header("Content-Type", "image/svg+xml")
}
if path, err := exec.LookPath(os.Args[0]); err == nil {
if file, err := os.Stat(path); err == nil {
c.Header("Last-Modified", file.ModTime().UTC().Format("Mon, 02 Jan 2006 15:04:05 GMT"))
}
}
if _, err := c.Writer.Write(data); err != nil {
c.AbortWithError(500, err)
return