mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
2978 files. The fork is 2026-07-15 (rebrand: gitea.dev -> github.com/hanzoai/git), so 2026 is the year, and "Copyright 2026 Hanzo AI, Inc." was already the form used by the handful of files that had ours. Shape is now: // Copyright 2026 Hanzo AI, Inc. All rights reserved. // Copyright 2015 The Gogs Authors. All rights reserved. // Copyright 2019 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT Ours on top, theirs retained verbatim. Retained because MIT requires it, and separately because they are true — those authors did write that code. Not renamed to "The Git Authors": Git is a different project under a different license, and putting its name here would attribute this code to people who have nothing to do with it. Adding our line is the fix; overwriting theirs would have been both a licence violation and a false statement. gofmt still reports import-order drift in some of these files. It predates this change (verified against a stash) and is left alone rather than burying a one-line-per-file legal change under 3000 files of unrelated reordering. Build clean. Co-authored-by: Hanzo Dev <[email protected]>
53 lines
1.7 KiB
Go
53 lines
1.7 KiB
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package install
|
|
|
|
import (
|
|
"fmt"
|
|
"html"
|
|
"net/http"
|
|
|
|
"github.com/hanzoai/git/modules/public"
|
|
"github.com/hanzoai/git/modules/setting"
|
|
"github.com/hanzoai/git/modules/web"
|
|
"github.com/hanzoai/git/routers/common"
|
|
"github.com/hanzoai/git/routers/web/healthcheck"
|
|
"github.com/hanzoai/git/routers/web/misc"
|
|
"github.com/hanzoai/git/services/forms"
|
|
)
|
|
|
|
// Routes registers the installation routes
|
|
func Routes() *web.Router {
|
|
base := web.NewRouter()
|
|
base.BeforeRouting(common.ProtocolMiddlewares()...)
|
|
|
|
base.Methods("GET, HEAD", "/assets/*", public.FileHandlerFunc())
|
|
|
|
r := web.NewRouter()
|
|
r.AfterRouting(common.MustInitSessioner(), installContexter())
|
|
|
|
r.Get("/", Install) // it must be on the root, because the "install.js" use the window.location to replace the "localhost" AppURL
|
|
r.Post("/", web.Bind(forms.InstallForm{}), SubmitInstall)
|
|
r.Get("/post-install", InstallDone)
|
|
|
|
r.Get("/-/web-theme/list", misc.WebThemeList)
|
|
r.Post("/-/web-theme/apply", misc.WebThemeApply)
|
|
r.Get("/v1/healthz", healthcheck.Check)
|
|
|
|
r.NotFound(installNotFound)
|
|
|
|
base.Mount("", r)
|
|
return base
|
|
}
|
|
|
|
func installNotFound(w http.ResponseWriter, req *http.Request) {
|
|
w.Header().Add("Content-Type", "text/html; charset=utf-8")
|
|
w.Header().Add("Refresh", "1; url="+setting.AppSubURL+"/")
|
|
// do not use 30x status, because the "post-install" page needs to use 404/200 to detect if Gitea has been installed.
|
|
// the fetch API could follow 30x requests to the page with 200 status.
|
|
w.WriteHeader(http.StatusNotFound)
|
|
_, _ = fmt.Fprintf(w, `Not Found. <a href="%s">Go to default page</a>.`, html.EscapeString(setting.AppSubURL+"/"))
|
|
}
|