mirror of
https://github.com/hay-kot/homebox.git
synced 2025-07-08 11:38:36 +00:00
feat: automate demo-site deployment and configuration (#42)
* add demo env variable * setup initialization when demo * disable password when in demo mode * expose demo status to API * improve UI for demo instance
This commit is contained in:
parent
eca071f974
commit
92368dabf8
12 changed files with 166 additions and 45 deletions
|
@ -13,9 +13,16 @@ func WithMaxUploadSize(maxUploadSize int64) func(*V1Controller) {
|
|||
}
|
||||
}
|
||||
|
||||
func WithDemoStatus(demoStatus bool) func(*V1Controller) {
|
||||
return func(ctrl *V1Controller) {
|
||||
ctrl.isDemo = demoStatus
|
||||
}
|
||||
}
|
||||
|
||||
type V1Controller struct {
|
||||
svc *services.AllServices
|
||||
maxUploadSize int64
|
||||
isDemo bool
|
||||
}
|
||||
|
||||
type (
|
||||
|
@ -30,7 +37,8 @@ type (
|
|||
Versions []string `json:"versions"`
|
||||
Title string `json:"title"`
|
||||
Message string `json:"message"`
|
||||
Build Build
|
||||
Build Build `json:"build"`
|
||||
Demo bool `json:"demo"`
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -48,6 +56,10 @@ func NewControllerV1(svc *services.AllServices, options ...func(*V1Controller))
|
|||
svc: svc,
|
||||
}
|
||||
|
||||
for _, opt := range options {
|
||||
opt(ctrl)
|
||||
}
|
||||
|
||||
return ctrl
|
||||
}
|
||||
|
||||
|
@ -66,6 +78,7 @@ func (ctrl *V1Controller) HandleBase(ready ReadyFunc, build Build) http.HandlerF
|
|||
Title: "Go API Template",
|
||||
Message: "Welcome to the Go API Template Application!",
|
||||
Build: build,
|
||||
Demo: ctrl.isDemo,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,6 +136,11 @@ type (
|
|||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleUserSelfChangePassword() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if ctrl.isDemo {
|
||||
server.RespondError(w, http.StatusForbidden, nil)
|
||||
return
|
||||
}
|
||||
|
||||
var cp ChangePassword
|
||||
err := server.Decode(r, &cp)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue