aboutsummaryrefslogtreecommitdiff
path: root/server.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-06 01:41:43 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-06 01:41:43 +0800
commit1351bbae5610caa1cb6ac9b727ff5296b157273c (patch)
tree01b2c081816dc75e06d32231948fed3d8df104d1 /server.go
parentEnsure server is ready before Run() (diff)
downloadforge-1351bbae5610caa1cb6ac9b727ff5296b157273c.tar.gz
forge-1351bbae5610caa1cb6ac9b727ff5296b157273c.tar.zst
forge-1351bbae5610caa1cb6ac9b727ff5296b157273c.zip
Slight refactor on NewServer
Diffstat (limited to 'server.go')
-rw-r--r--server.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/server.go b/server.go
index fdedf3c..3a90e1c 100644
--- a/server.go
+++ b/server.go
@@ -49,14 +49,18 @@ type Server struct {
ready bool
}
-func (s *Server) Setup() {
+func (s *Server) NewServer(configPath string) error {
+ if err := s.loadConfig(configPath); err != nil {
+ return err
+ }
+
s.sourceHandler = http.StripPrefix(
"/-/source/",
http.FileServer(http.FS(embeddedSourceFS)),
)
staticFS, err := fs.Sub(embeddedResourcesFS, "static")
if err != nil {
- panic(err)
+ return err
}
s.staticHandler = http.StripPrefix("/-/static/", http.FileServer(http.FS(staticFS)))
s.globalData = map[string]any{
@@ -72,6 +76,8 @@ func (s *Server) Setup() {
misc.NoneOrPanic(os.Chmod(filepath.Join(s.config.Hooks.Execs, "pre-receive"), 0o755))
s.ready = true
+
+ return nil
}
func (s *Server) Run() error {