Moved server packages to a separate folder
This commit is contained in:
3
utils/README.md
Normal file
3
utils/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# utils
|
||||
|
||||
This folder should be deleted in future versions.
|
@ -1,43 +0,0 @@
|
||||
package https
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/akyoto/color"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
)
|
||||
|
||||
// Configure loads the certificates.
|
||||
func Configure(app *aero.Application) {
|
||||
fullCertPath := path.Join(arn.Root, "security", "fullchain.pem")
|
||||
fullKeyPath := path.Join(arn.Root, "security", "privkey.pem")
|
||||
|
||||
if _, err := os.Stat(fullCertPath); os.IsNotExist(err) {
|
||||
defaultCertPath := path.Join(arn.Root, "security", "default", "server.crt")
|
||||
err := os.Link(defaultCertPath, fullCertPath)
|
||||
|
||||
if err != nil {
|
||||
// Do not panic here, multiple tests could be running this in parallel.
|
||||
// Therefore, races can occur (which test writes the link first).
|
||||
// Simply log the error and continue as the file should be present.
|
||||
color.Red(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := os.Stat(fullKeyPath); os.IsNotExist(err) {
|
||||
defaultKeyPath := path.Join(arn.Root, "security", "default", "server.key")
|
||||
err := os.Link(defaultKeyPath, fullKeyPath)
|
||||
|
||||
if err != nil {
|
||||
// Do not panic here, multiple tests could be running this in parallel.
|
||||
// Therefore, races can occur (which test writes the link first).
|
||||
// Simply log the error and continue as the file should be present.
|
||||
color.Red(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// HTTPS
|
||||
app.Security.Load(fullCertPath, fullKeyPath)
|
||||
}
|
@ -2,7 +2,7 @@ package page
|
||||
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/notify.moe/middleware"
|
||||
"github.com/animenotifier/notify.moe/server/middleware"
|
||||
)
|
||||
|
||||
// Get registers a layout rendered route and a contents-only route.
|
||||
|
Reference in New Issue
Block a user