Skip to content

Commit

Permalink
Upgraded to latest Aero version
Browse files Browse the repository at this point in the history
  • Loading branch information
akyoto committed Dec 4, 2019
1 parent 3d8a8c7 commit a9475b7
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 105 deletions.
31 changes: 14 additions & 17 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
MIT License
Sponsorship License

Copyright (c) 2018 Eduard Urbach
Copyright (c) 2019 Eduard Urbach

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
* You are permitted to use the software freely for non-commercial purposes.
* You MUST be a sponsor donating at least 10 USD every month to me if you use the software for commercial purposes.

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
To become a sponsor:

1. Visit the following page: https://github.com/users/akyoto/sponsorship
2. Register as a sponsor for the 10 USD per month tier.

Additional notes:

* Canceling your sponsorship will also revoke the rights to use the software for commercial purposes.
* The software is provided "as is", without warranty of any kind.
* The above copyright notice and this permission must be included in all copies of the software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 2 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"main": "main"
},
"push": [
"/scripts",
"/styles"
"/styles",
"/scripts"
],
"ports": {
"http": 4000,
Expand Down
9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ module github.com/konnakanji/konnakanji
go 1.13

require (
github.com/aerogo/aero v1.3.28
github.com/aerogo/aero v1.3.50
github.com/aerogo/manifest v0.1.5
github.com/akyoto/assert v0.2.3
github.com/akyoto/color v1.8.10
github.com/akyoto/hash v0.4.8 // indirect
github.com/akyoto/assert v0.2.4
github.com/akyoto/color v1.8.11
github.com/json-iterator/go v1.1.8 // indirect
golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 // indirect
)
84 changes: 32 additions & 52 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,47 +1,32 @@
github.com/aerogo/aero v1.3.28 h1:ZoDvLxG4xUnH3YQd8FjLIQpi43ALOWq+DbBRwyvpS/c=
github.com/aerogo/aero v1.3.28/go.mod h1:WZq4j2dr9BbbyqBxhV8kOGpnyMI+1bkDKhFrvmlSn7c=
github.com/aerogo/csp v0.1.9 h1:7K8FujZkE62Wes0lXt9sTG0kf/pn3G3XkDwhmrTlnpY=
github.com/aerogo/csp v0.1.9/go.mod h1:xB+51XmDvkdRYsOCwVoG/D+aJGEJfi6KxqM3/zf2jZw=
github.com/aerogo/http v1.0.9 h1:ddgS613r1/XNNayvlQK1/hnSoR2GCOzIeO6wL0x84gQ=
github.com/aerogo/http v1.0.9/go.mod h1:qVlq+QszT9mFVL92hmMs71fqzA1DILTjNSucEWUdFmk=
github.com/aerogo/http v1.0.10 h1:CIFhdka8DjJ/vF2oxQVi+1lNi7LZp5xSmkEjbEwhrdI=
github.com/aerogo/http v1.0.10/go.mod h1:rG/KkSLgpcjuB9I8k+OWbQI9YbahHIridyva0AQdH70=
github.com/aerogo/linter-performance v1.0.5 h1:2tNBov+S/zuJ7Z0t2Yif2AYTfviNavJEGtfm1Sjyap4=
github.com/aerogo/linter-performance v1.0.5/go.mod h1:Frqz5+t0UnhaLy+zqU8FSXBne5D9Tt06EZh1ug2HZyY=
github.com/aerogo/aero v1.3.50 h1:6iUBAijs7XVLmTaOaKJ28SNvmD44UbS/LMm1wWOBFrg=
github.com/aerogo/aero v1.3.50/go.mod h1:3q0urf+LYebjm7rsfYpH0lYK2GvOeF0XVspgxKJCbqE=
github.com/aerogo/csp v0.1.10 h1:2PJf9gkdRvCFYOA0baTUyp34vwPp5ZJJX8GZRCYc/nM=
github.com/aerogo/csp v0.1.10/go.mod h1:UrxbTXv+X9kJatyuLeu2yGFpOiWVPjbqA/DzqxSVhl8=
github.com/aerogo/http v1.1.2/go.mod h1:h+m3WxevpaifyVpRAMV58qt8ScXSZhU1a5DdvBkRwwE=
github.com/aerogo/http v1.1.3 h1:cvwOYL+zNEfNHvJcX6A6OgUwQ4KROlu8ypuQEQc1HtU=
github.com/aerogo/http v1.1.3/go.mod h1:h+m3WxevpaifyVpRAMV58qt8ScXSZhU1a5DdvBkRwwE=
github.com/aerogo/linter-performance v1.0.7 h1:8a+GBJl8JP7NobmEN8wtuhxHOUr77Yazzq8sxdFJzuQ=
github.com/aerogo/linter-performance v1.0.7/go.mod h1:F5uPm704+MFf3BL8d1tYs50giZRtxM49nefGW+QjLW4=
github.com/aerogo/manifest v0.1.5 h1:tx3ZqBCbUgydiKDVzFS+ZXsEpD1JaZXE8lHzrhaHU68=
github.com/aerogo/manifest v0.1.5/go.mod h1:8puKQdv9gfB9tbFewIV1Pnox9Sy0JuQi+/kxOKWjRCk=
github.com/aerogo/session v0.1.7 h1:Natc9Pq9KIHDUBR/0YjdazckTdOWBItYmuDplGJJfFc=
github.com/aerogo/session v0.1.7/go.mod h1:6/99zuiGm8wzIPFGDlzv3636eLqhWR9cf0rRn/3IRJs=
github.com/aerogo/session-store-memory v0.1.6 h1:CZFuEkhL1NV4EFSwerPokuYHtYDXrePAipau/6xyM0Y=
github.com/aerogo/session-store-memory v0.1.6/go.mod h1:k3ElPubm0b+V/DV+pgtCLSArro/jbdS7niJ8uTKkvAQ=
github.com/akyoto/assert v0.1.3/go.mod h1:g5e6ag+ksCEQENq/LnmU9z04wCAIFDr8KacBusVL0H8=
github.com/akyoto/assert v0.2.0 h1:lR7OHrbbBNNZFmRVS8I5MzS0ShLH36ZQVZVyg1bvs6A=
github.com/akyoto/assert v0.2.0/go.mod h1:g5e6ag+ksCEQENq/LnmU9z04wCAIFDr8KacBusVL0H8=
github.com/akyoto/assert v0.2.1/go.mod h1:g5e6ag+ksCEQENq/LnmU9z04wCAIFDr8KacBusVL0H8=
github.com/aerogo/session v0.1.8 h1:l28Ii/YBfh4/vDWOc1YXLXg2vkHsRFuMLAeVhhl1eME=
github.com/aerogo/session v0.1.8/go.mod h1:Q9QqpT8nM6HTaklE14T+bzNSKrwW1M2wZ/NZV1HUTB0=
github.com/aerogo/session v0.1.9 h1:pgsFEtCteOQaZ/103q2/O+qrqZileiCZe+vboWKZMlU=
github.com/aerogo/session v0.1.9/go.mod h1:dgpdXvs9tZXcag5ay6tEoKuySPga226iSh748uIES/E=
github.com/aerogo/session-store-memory v0.1.9 h1:1OswTCtyqzffX5aGr6jI3H8gt/hkU3LKNiKpia7ntcs=
github.com/aerogo/session-store-memory v0.1.9/go.mod h1:z4ZxP+xLVdH69F/Cvgy93v8fWzeDmiJo+Mm+Th3un4c=
github.com/akyoto/assert v0.2.3 h1:ftENRGDEK5AKuKmZb9LtbDIHeE8p8cIYI4M92CbA9nE=
github.com/akyoto/assert v0.2.3/go.mod h1:g5e6ag+ksCEQENq/LnmU9z04wCAIFDr8KacBusVL0H8=
github.com/akyoto/color v1.8.7 h1:Sr9z8iFoFF9KMJpHmQH+raFaVrO3wHNFIkFdyQdTsVY=
github.com/akyoto/color v1.8.7/go.mod h1:eNfGr527GIJME/houfnrEIGiVlL5IJsOfuC2I+oby+4=
github.com/akyoto/color v1.8.9 h1:Uv8/rFdvq06ntG+GibKjbT+jWtc6o88SjKMUmi1Nom8=
github.com/akyoto/color v1.8.9/go.mod h1:ImvfyQaQbqtKLwiafRiRu6Fq98f4f9HBI/J0WK7q3Oc=
github.com/akyoto/color v1.8.10 h1:rTUy7YcIthIOyvRDL/xKYIuDrxqijATzzf5gxVKllko=
github.com/akyoto/color v1.8.10/go.mod h1:WMx6CKtRh0Y4DUP0wwKrLdaqPr2bwrAamzYF0By73QU=
github.com/akyoto/colorable v0.1.4 h1:BPwbsaUmo90/JiwTB7v7TpRHkNsfIxsb9s25eASwwDg=
github.com/akyoto/colorable v0.1.4/go.mod h1:AUfZwbC9OzwBaIbVTyNpD2UmwPbh3ZQqpyrHzb2ZymY=
github.com/akyoto/colorable v0.1.6 h1:F1TIfFIO3NEjkUffwjpzHkQ4dGm3jhnDXH53cyXAuvc=
github.com/akyoto/colorable v0.1.6/go.mod h1:xPL/NZl7l8HzMShbqGXYOgMT7pfQbwk3CwRGY70IchA=
github.com/akyoto/hash v0.4.7 h1:z5yF4PPuzUqmSHVK6poV3UVFw+zR+/8IGDAy+zsR+U8=
github.com/akyoto/hash v0.4.7/go.mod h1:BSMAz3ncYc7mbb8VZlAo2nLIYPVB9QQ2SDsev7NJFmg=
github.com/akyoto/hash v0.4.8 h1:4PdsvyWLon+nMHsP4tZEZb7MiNFil16XqdwyWpY+uaQ=
github.com/akyoto/hash v0.4.8/go.mod h1:ukwV/qacn7OahWH01ogEYvmS4Y0y5yZpauSRhWTdmR8=
github.com/akyoto/stringutils v0.2.3 h1:ggwgzXEXEj5SPtZr/7uYC+creqvz33UfWz37561/no4=
github.com/akyoto/stringutils v0.2.3/go.mod h1:nyO78pc92gciYObsOGWasnQN/s18JEQusXtN/7iC2AM=
github.com/akyoto/stringutils v0.2.4 h1:VYW2FH2qjmQyJWZDSNFSP8btbSwJDoY0x14uiD/0OLU=
github.com/akyoto/stringutils v0.2.4/go.mod h1:nyO78pc92gciYObsOGWasnQN/s18JEQusXtN/7iC2AM=
github.com/akyoto/tty v0.1.0/go.mod h1:UMkevvI7yitoMBNoA9ALtJU0AL/6XGNkyuh9DqPvIOs=
github.com/akyoto/tty v0.1.1 h1:ZOJpp9fj0Y0CNVl9j7MJ7sJvlf9yVlFyDTiahD8FbUo=
github.com/akyoto/tty v0.1.1/go.mod h1:DLx0iz7IeaEsdXQkZ5IN/YOoWRvuV+JOSy6AQjyxA50=
github.com/akyoto/tty v0.1.2/go.mod h1:+VlbvviCaiwhS4oGpO+iBtC0lYG1ilIs3ZhUnT1Ppgo=
github.com/akyoto/assert v0.2.4 h1:n0FwcNH5dMYq3I8Iu7MOR1WWGkkGH8ao84nvCRJmsbs=
github.com/akyoto/assert v0.2.4/go.mod h1:SoqVayyOmM/YSBnwOxJHCt4BCocoIrgeceWtJV701C0=
github.com/akyoto/color v1.8.11 h1:uCQi+uRyngo1cJhJSv28PQmduGFiOAGNF6F9MFoRDek=
github.com/akyoto/color v1.8.11/go.mod h1:Q77HnNKrgGSfXOpkR7cuyazaOXQsKLWKbDPh2cy+jto=
github.com/akyoto/colorable v0.1.7 h1:ge91E25hiOiT/Zu47ij/rTO3cks7wMlTrcQspua1hFM=
github.com/akyoto/colorable v0.1.7/go.mod h1:zlc1+Es4DyoXzDdbKiSfvdM6R/DsWS8bFi4RHigkuu4=
github.com/akyoto/hash v0.4.9 h1:lXuecH+SDLVpFksM92KIblB4MBt4lnrMP1LgWmXs2y4=
github.com/akyoto/hash v0.4.9/go.mod h1:lJFW7lsB614OqY06AccDTtJfk0kKWkzM3x8dWzMo+K0=
github.com/akyoto/stringutils v0.3.1 h1:C+VGuXfud9SSo54QRfdQO+rgQiHmLS5f4nJ4yUOM+8I=
github.com/akyoto/stringutils v0.3.1/go.mod h1:I1F9f8FF7gnAQyYp4PVAl+GJ2WBnaN6kNoYjidCV5Qk=
github.com/akyoto/tty v0.1.3 h1:AdnLETzgooimWLvoBQLn5bT1j+i0yiB4E596BfFKnmA=
github.com/akyoto/tty v0.1.3/go.mod h1:+VlbvviCaiwhS4oGpO+iBtC0lYG1ilIs3ZhUnT1Ppgo=
github.com/akyoto/uuid v1.1.3 h1:FEz14tNTfaUeY0Jrkz2F17rjKiks6hOALGcPmAmtn1s=
Expand All @@ -52,17 +37,13 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo=
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.8 h1:QiWkFLKq0T7mpzwOTu6BzNDbfTE8OLrYhVKYMLF46Ok=
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.9 h1:d5US/mDsogSGW37IV293h//ZFaeajb69h+EHFsv2xGg=
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand All @@ -76,17 +57,16 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/zeebo/xxh3 v0.0.0-20190923153500-83a7230063d0/go.mod h1:e/zZObEJWtkq6f+bAzme0xQJSGI75oxoeqS+f2I7YVI=
github.com/zeebo/xxh3 v0.0.0-20191021174148-b56a7dc3d80c h1:3PaZXPP1fMCBSQzwmcfLs0pX9wOeZpKduDDcvp6lKCc=
github.com/zeebo/xxh3 v0.0.0-20191021174148-b56a7dc3d80c/go.mod h1:e/zZObEJWtkq6f+bAzme0xQJSGI75oxoeqS+f2I7YVI=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190910064555-bbd175535a8b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191007154456-ef33b2fb2c41/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191018095205-727590c5006e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191025090151-53bf42e6b339 h1:zSqWKgm/o7HAnlAzBQ+aetp9fpuyytsXnKA8eiLHYQM=
golang.org/x/sys v0.0.0-20191025090151-53bf42e6b339/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191127021746-63cb32ae39b2 h1:/J2nHFg1MTqaRLFO7M+J78ASNsJoz3r0cvHBPQ77fsE=
golang.org/x/sys v0.0.0-20191127021746-63cb32ae39b2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 h1:ZBzSG/7F4eNKz2L3GE9o300RX0Az1Bw5HF7PDraD+qU=
golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
4 changes: 2 additions & 2 deletions layout/layout.pixy
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
component Layout(ctx *aero.Context)
component Layout(ctx aero.Context)
html(lang="en")
head
link(rel="stylesheet", href="/styles")
link(rel="manifest", href="/manifest.json")
link(rel="shortcut icon", type="image/png", href="/images/brand/192.png")

title= ctx.App.Config.Title
title= assets.Manifest.Name

meta(name="viewport", content="width=device-width, initial-scale=1, user-scalable=no")
meta(name="theme-color", content=assets.Manifest.ThemeColor)
Expand Down
31 changes: 16 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,55 @@ import (
"github.com/konnakanji/konnakanji/components"
)

var mainApp = aero.New()

func main() {
configure(mainApp).Run()
app := aero.New()
configure(app).Run()
}

func configure(app *aero.Application) *aero.Application {
configureHTTPS(app)
assets.Load()

appCode := func(ctx *aero.Context) string {
appCode := func(ctx aero.Context) error {
return ctx.HTML(components.Layout(ctx))
}

app.Get("/", appCode)
app.Get("/test/*name", appCode)

app.Get("/scripts", func(ctx *aero.Context) string {
app.Get("/scripts", func(ctx aero.Context) error {
return ctx.JavaScript(assets.JS)
})

app.Get("/styles", func(ctx *aero.Context) string {
app.Get("/styles", func(ctx aero.Context) error {
return ctx.CSS(assets.CSS)
})

app.Get("/manifest.json", func(ctx *aero.Context) string {
app.Get("/manifest.json", func(ctx aero.Context) error {
return ctx.JSON(assets.Manifest)
})

app.Get("/words/*file", func(ctx *aero.Context) string {
app.Get("/words/*file", func(ctx aero.Context) error {
return ctx.File("words/" + ctx.Get("file"))
})

app.Get("/images/*file", func(ctx *aero.Context) string {
app.Get("/images/*file", func(ctx aero.Context) error {
return ctx.File("images/" + ctx.Get("file"))
})

app.Get("/service-worker", func(ctx *aero.Context) string {
app.Get("/service-worker", func(ctx aero.Context) error {
return ctx.File("scripts/ServiceWorker/ServiceWorker.js")
})

// Send "Link" header for Cloudflare on HTML responses
app.Use(func(ctx *aero.Context, next func()) {
if !strings.HasPrefix(ctx.URI(), "/_/") && strings.Contains(ctx.Request().Header().Get("Accept"), "text/html") {
ctx.Response().Header().Set("Link", "</styles>; rel=preload; as=style,</scripts>; rel=preload; as=script")
}
app.Use(func(next aero.Handler) aero.Handler {
return func(ctx aero.Context) error {
if !strings.HasPrefix(ctx.Path(), "/_/") && strings.Contains(ctx.Request().Header("Accept"), "text/html") {
ctx.Response().SetHeader("Link", "</styles>; rel=preload; as=style,</scripts>; rel=preload; as=script")
}

next()
return next(ctx)
}
})

return app
Expand Down
15 changes: 2 additions & 13 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,20 @@ package main
import (
"net/http"
"net/http/httptest"
"syscall"
"testing"
"time"

"github.com/aerogo/aero"
"github.com/stretchr/testify/assert"
"github.com/akyoto/assert"
)

func TestMain(t *testing.T) {
mainApp.OnStart(func() {
time.Sleep(1 * time.Second)
syscall.Kill(syscall.Getpid(), syscall.SIGINT)
})

go main()
}

func TestFrontPage(t *testing.T) {
app := configure(aero.New())

request, _ := http.NewRequest("GET", "/", nil)
request.Header.Set("Accept-Encoding", "gzip")

response := httptest.NewRecorder()
app.Handler().ServeHTTP(response, request)
app.ServeHTTP(response, request)

assert.Equal(t, http.StatusOK, response.Code)
}

0 comments on commit a9475b7

Please sign in to comment.