Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
Serve SPA client
Browse files Browse the repository at this point in the history
  • Loading branch information
td0m committed Feb 3, 2019
1 parent dd63826 commit a04a713
Show file tree
Hide file tree
Showing 15 changed files with 105 additions and 5 deletions.
13 changes: 13 additions & 0 deletions client/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"main.css": "/static/css/main.a546e8d7.chunk.css",
"main.js": "/static/js/main.80550e75.chunk.js",
"main.js.map": "/static/js/main.80550e75.chunk.js.map",
"static/js/1.26fde670.chunk.js": "/static/js/1.26fde670.chunk.js",
"static/js/1.26fde670.chunk.js.map": "/static/js/1.26fde670.chunk.js.map",
"runtime~main.js": "/static/js/runtime~main.229c360f.js",
"runtime~main.js.map": "/static/js/runtime~main.229c360f.js.map",
"static/css/main.a546e8d7.chunk.css.map": "/static/css/main.a546e8d7.chunk.css.map",
"index.html": "/index.html",
"precache-manifest.e3c0af01bdde1575ae9fe3736d9e201a.js": "/precache-manifest.e3c0af01bdde1575ae9fe3736d9e201a.js",
"service-worker.js": "/service-worker.js"
}
Binary file added client/build/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions 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="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link href="https://fonts.googleapis.com/css?family=Roboto+Mono:300,400,500|Major+Mono+Display:400|Material+Icons" rel="stylesheet"><link rel="manifest" href="/manifest.json"/><title>Dragons</title><link href="/static/css/main.a546e8d7.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(l){function e(e){for(var r,t,n=e[0],o=e[1],u=e[2],f=0,i=[];f<n.length;f++)t=n[f],p[t]&&i.push(p[t][0]),p[t]=0;for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(l[r]=o[r]);for(s&&s(e);i.length;)i.shift()();return c.push.apply(c,u||[]),a()}function a(){for(var e,r=0;r<c.length;r++){for(var t=c[r],n=!0,o=1;o<t.length;o++){var u=t[o];0!==p[u]&&(n=!1)}n&&(c.splice(r--,1),e=f(f.s=t[0]))}return e}var t={},p={2:0},c=[];function f(e){if(t[e])return t[e].exports;var r=t[e]={i:e,l:!1,exports:{}};return l[e].call(r.exports,r,r.exports,f),r.l=!0,r.exports}f.m=l,f.c=t,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(r,e){if(1&e&&(r=f(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var n in r)f.d(t,n,function(e){return r[e]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var r=window.webpackJsonp=window.webpackJsonp||[],n=r.push.bind(r);r.push=e,r=r.slice();for(var o=0;o<r.length;o++)e(r[o]);var s=n;a()}([])</script><script src="/static/js/1.26fde670.chunk.js"></script><script src="/static/js/main.80550e75.chunk.js"></script></body></html>
15 changes: 15 additions & 0 deletions client/build/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
22 changes: 22 additions & 0 deletions client/build/precache-manifest.e3c0af01bdde1575ae9fe3736d9e201a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
self.__precacheManifest = [
{
"revision": "80550e759a4ec66885bb",
"url": "/static/css/main.a546e8d7.chunk.css"
},
{
"revision": "80550e759a4ec66885bb",
"url": "/static/js/main.80550e75.chunk.js"
},
{
"revision": "26fde6705b405ee47e42",
"url": "/static/js/1.26fde670.chunk.js"
},
{
"revision": "229c360febb4351a89df",
"url": "/static/js/runtime~main.229c360f.js"
},
{
"revision": "8d635cac6d992f6acb8a06ee7494e9c7",
"url": "/index.html"
}
];
34 changes: 34 additions & 0 deletions client/build/service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Welcome to your Workbox-powered service worker!
*
* You'll need to register this file in your web app and you should
* disable HTTP caching for this file too.
* See https://goo.gl/nhQhGp
*
* The rest of the code is auto-generated. Please don't update this file
* directly; instead, make changes to your Workbox build configuration
* and re-run your build process.
* See https://goo.gl/2aRDsh
*/

importScripts("https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-sw.js");

importScripts(
"/precache-manifest.e3c0af01bdde1575ae9fe3736d9e201a.js"
);

workbox.clientsClaim();

/**
* The workboxSW.precacheAndRoute() method efficiently caches and responds to
* requests for URLs in the manifest.
* See https://goo.gl/S9QRab
*/
self.__precacheManifest = [].concat(self.__precacheManifest || []);
workbox.precaching.suppressWarnings();
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});

workbox.routing.registerNavigationRoute("/index.html", {

blacklist: [/^\/_/,/\/[^\/]+\.[^\/]+$/],
});
2 changes: 2 additions & 0 deletions client/build/static/css/main.a546e8d7.chunk.css

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

1 change: 1 addition & 0 deletions client/build/static/css/main.a546e8d7.chunk.css.map

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

2 changes: 2 additions & 0 deletions client/build/static/js/1.26fde670.chunk.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client/build/static/js/1.26fde670.chunk.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions client/build/static/js/main.80550e75.chunk.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client/build/static/js/main.80550e75.chunk.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions client/build/static/js/runtime~main.229c360f.js

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

1 change: 1 addition & 0 deletions client/build/static/js/runtime~main.229c360f.js.map

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

13 changes: 8 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"net/http"
"os"
"path"
"reflect"

"github.com/d0minikt/dragons/lib"
Expand Down Expand Up @@ -159,10 +160,6 @@ func handleWebsocketConnection(w http.ResponseWriter, r *http.Request) {
}
}

func home(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello world"))
}

func main() {
port := os.Getenv("PORT")
if port == "" {
Expand All @@ -173,7 +170,13 @@ func main() {
flag.Parse()
log.SetFlags(0)
http.HandleFunc("/ws", handleWebsocketConnection)
http.HandleFunc("/", home)

// spa
wd, _ := os.Getwd()
dir := path.Join(wd, "/client/build/")
fs := http.FileServer(http.Dir(dir))
http.Handle("/", fs)

log.Fatal(http.ListenAndServe(*addr, nil))
}

Expand Down

0 comments on commit a04a713

Please sign in to comment.