Skip to content

Commit

Permalink
add web dist files to make go install work
Browse files Browse the repository at this point in the history
  • Loading branch information
lqqyt2423 committed Jun 28, 2024
1 parent 3075a64 commit 40c3298
Show file tree
Hide file tree
Showing 19 changed files with 121 additions and 34 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ jobs:
with:
fetch-depth: 0

- uses: actions/setup-node@v4
with:
node-version: 20
- run: yarn install
working-directory: web/client
- run: yarn build
working-directory: web/client

- name: Set up Go
uses: actions/setup-go@v4
with:
Expand Down
16 changes: 16 additions & 0 deletions web/client/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"files": {
"main.css": "/static/css/main.15b22d69.css",
"main.js": "/static/js/main.66901bf9.js",
"static/js/496.aae294ae.chunk.js": "/static/js/496.aae294ae.chunk.js",
"static/media/github-mark.svg": "/static/media/github-mark.6fa18895f6e6c7772cab7049f7e05f59.svg",
"index.html": "/index.html",
"main.15b22d69.css.map": "/static/css/main.15b22d69.css.map",
"main.66901bf9.js.map": "/static/js/main.66901bf9.js.map",
"496.aae294ae.chunk.js.map": "/static/js/496.aae294ae.chunk.js.map"
},
"entrypoints": [
"static/css/main.15b22d69.css",
"static/js/main.66901bf9.js"
]
}
Binary file added web/client/build/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions web/client/build/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>go-mitmproxy</title><script defer="defer" src="/static/js/main.66901bf9.js"></script><link href="/static/css/main.15b22d69.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
Binary file added web/client/build/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/client/build/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions web/client/build/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 0 additions & 3 deletions web/client/build/readme.txt

This file was deleted.

3 changes: 3 additions & 0 deletions web/client/build/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
7 changes: 7 additions & 0 deletions web/client/build/static/css/main.15b22d69.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions web/client/build/static/css/main.15b22d69.css.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions web/client/build/static/js/496.aae294ae.chunk.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions web/client/build/static/js/496.aae294ae.chunk.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions web/client/build/static/js/main.66901bf9.js

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions web/client/build/static/js/main.66901bf9.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/

/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
1 change: 1 addition & 0 deletions web/client/build/static/js/main.66901bf9.js.map

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion web/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"scripts": {
"start": "react-scripts start",
"build": "BUILD_PATH=build/dist react-scripts build",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Expand Down
36 changes: 14 additions & 22 deletions web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,23 @@ func NewWebAddon(addr string) *WebAddon {
flowMessageState: make(map[*proxy.Flow]messageType),
}

_, err := assets.ReadDir("client/build/dist")
if err != nil {
web.server = &http.Server{
Addr: addr,
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
fmt.Fprintf(w, `Please build frontend: "cd web/client; yarn build"`)
}),
}
} else {
web.upgrader = &websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
},
}

serverMux := new(http.ServeMux)
serverMux.HandleFunc("/echo", web.echo)
web.upgrader = &websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
},
}

fsys, _ := fs.Sub(assets, "client/build/dist")
serverMux.Handle("/", http.FileServer(http.FS(fsys)))
serverMux := new(http.ServeMux)
serverMux.HandleFunc("/echo", web.echo)

web.server = &http.Server{Addr: addr, Handler: serverMux}
web.conns = make([]*concurrentConn, 0)
fsys, err := fs.Sub(assets, "client/build")
if err != nil {
panic(err)
}
serverMux.Handle("/", http.FileServer(http.FS(fsys)))

web.server = &http.Server{Addr: addr, Handler: serverMux}
web.conns = make([]*concurrentConn, 0)

go func() {
log.Infof("web interface start listen at %v\n", addr)
Expand Down

0 comments on commit 40c3298

Please sign in to comment.