mirror of
https://github.com/Monibuca/plugin-jessica.git
synced 2025-09-27 04:16:04 +08:00
使用Utils包
This commit is contained in:
3
go.mod
3
go.mod
@@ -4,9 +4,10 @@ go 1.13
|
||||
|
||||
require (
|
||||
github.com/Monibuca/engine/v2 v2.0.0
|
||||
github.com/Monibuca/utils v1.0.0 // indirect
|
||||
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee // indirect
|
||||
github.com/gobwas/pool v0.2.0 // indirect
|
||||
github.com/gobwas/ws v1.0.2
|
||||
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
|
||||
)
|
||||
|
4
go.sum
4
go.sum
@@ -8,6 +8,8 @@ github.com/Monibuca/engine/v2 v2.0.0-alpha2 h1:45yazqnnxEEcfHcOJGuIr1xtnBzQT6cPv
|
||||
github.com/Monibuca/engine/v2 v2.0.0-alpha2/go.mod h1:34EYjjV15G6myuHOKaJkO7y5tJ1Arq/NfC9Weacr2mc=
|
||||
github.com/Monibuca/engine/v2 v2.0.0 h1:8FjaScrtN8QdbcxO9zZYABMC0Re3I1O1T4p94zAXYb0=
|
||||
github.com/Monibuca/engine/v2 v2.0.0/go.mod h1:34EYjjV15G6myuHOKaJkO7y5tJ1Arq/NfC9Weacr2mc=
|
||||
github.com/Monibuca/utils v1.0.0 h1:hbRvlDAzClTXtIQIeY1PMqkL36TWyRCLNULjY/sOT3w=
|
||||
github.com/Monibuca/utils v1.0.0/go.mod h1:Iw3OnscHv6RFoi9nHdVLdPKkI9UfFmU5TgSQkMf+Yi8=
|
||||
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
|
||||
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
|
||||
github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A=
|
||||
@@ -52,6 +54,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
|
||||
golang.org/x/net v0.0.0-20200226051749-491c5fce7268/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=
|
||||
|
17
main.go
17
main.go
@@ -2,7 +2,6 @@ package jessica
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"mime"
|
||||
"net/http"
|
||||
"path"
|
||||
@@ -10,8 +9,8 @@ import (
|
||||
"strings"
|
||||
|
||||
. "github.com/Monibuca/engine/v2"
|
||||
"github.com/Monibuca/utils"
|
||||
. "github.com/logrusorgru/aurora"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
var config = &struct {
|
||||
@@ -36,19 +35,7 @@ func init() {
|
||||
func run() {
|
||||
Print(Green("server Jessica start at"), BrightBlue(config.ListenAddr))
|
||||
http.HandleFunc("/jessibuca/", jessibuca)
|
||||
var g errgroup.Group
|
||||
if config.ListenAddrTLS != "" {
|
||||
g.Go(func() error {
|
||||
return http.ListenAndServeTLS(config.ListenAddrTLS, config.CertFile, config.KeyFile, http.HandlerFunc(WsHandler))
|
||||
})
|
||||
}
|
||||
if config.ListenAddr != "" {
|
||||
g.Go(func() error { return http.ListenAndServe(config.ListenAddr, http.HandlerFunc(WsHandler)) })
|
||||
}
|
||||
if err := g.Wait(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
utils.ListenAddrs(config.ListenAddr, config.ListenAddrTLS, config.CertFile, config.KeyFile, http.HandlerFunc(WsHandler))
|
||||
}
|
||||
func jessibuca(w http.ResponseWriter, r *http.Request) {
|
||||
filePath := strings.TrimPrefix(r.URL.Path, "/jessibuca")
|
||||
|
Reference in New Issue
Block a user