Compare commits

..

6 Commits

Author SHA1 Message Date
01073aca78 latest
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is passing
2023-01-30 00:15:38 -08:00
49709ad3d2 latest
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2023-01-28 19:05:02 -08:00
3f49d528e7 builds and runs! not sure if it works, needs testing
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2022-11-28 06:00:44 +01:00
46b67f8a6e more progress
Some checks failed
continuous-integration/drone/push Build is failing
2022-11-28 05:33:52 +01:00
5fc22c36b0 getting closer
Some checks failed
continuous-integration/drone/push Build is failing
2022-11-28 05:09:23 +01:00
75442d261d this is nowhere near working yet
Some checks failed
continuous-integration/drone/push Build is failing
2022-11-28 04:59:20 +01:00
3 changed files with 61 additions and 19 deletions

View File

@ -26,15 +26,18 @@ type ConfigParams struct {
} }
type Config struct { type Config struct {
DBURL string DBURL string
Debug bool Debug bool
MaintenanceMode bool MaintenanceMode bool
MetricsPassword string DevelopmentMode bool
MetricsUsername string DevAdminUsername string
Port int DevAdminPassword string
SentryDSN string MetricsPassword string
params *ConfigParams MetricsUsername string
log *zerolog.Logger Port int
SentryDSN string
params *ConfigParams
log *zerolog.Logger
} }
func New(lc fx.Lifecycle, params ConfigParams) (*Config, error) { func New(lc fx.Lifecycle, params ConfigParams) (*Config, error) {
@ -52,6 +55,9 @@ func New(lc fx.Lifecycle, params ConfigParams) (*Config, error) {
viper.SetDefault("DEBUG", "false") viper.SetDefault("DEBUG", "false")
viper.SetDefault("MAINTENANCE_MODE", "false") viper.SetDefault("MAINTENANCE_MODE", "false")
viper.SetDefault("DEVELOPMENT_MODE", "false")
viper.SetDefault("DEV_ADMIN_USERNAME", "")
viper.SetDefault("DEV_ADMIN_PASSWORD", "")
viper.SetDefault("PORT", "8080") viper.SetDefault("PORT", "8080")
viper.SetDefault("DBURL", "") viper.SetDefault("DBURL", "")
viper.SetDefault("SENTRY_DSN", "") viper.SetDefault("SENTRY_DSN", "")
@ -70,15 +76,18 @@ func New(lc fx.Lifecycle, params ConfigParams) (*Config, error) {
} }
s := &Config{ s := &Config{
DBURL: viper.GetString("DBURL"), DBURL: viper.GetString("DBURL"),
Debug: viper.GetBool("debug"), Debug: viper.GetBool("debug"),
Port: viper.GetInt("PORT"), Port: viper.GetInt("PORT"),
SentryDSN: viper.GetString("SENTRY_DSN"), SentryDSN: viper.GetString("SENTRY_DSN"),
MaintenanceMode: viper.GetBool("MAINTENANCE_MODE"), MaintenanceMode: viper.GetBool("MAINTENANCE_MODE"),
MetricsUsername: viper.GetString("METRICS_USERNAME"), DevelopmentMode: viper.GetBool("DEVELOPMENT_MODE"),
MetricsPassword: viper.GetString("METRICS_PASSWORD"), DevAdminUsername: viper.GetString("DEV_ADMIN_USERNAME"),
log: log, DevAdminPassword: viper.GetString("DEV_ADMIN_PASSWORD"),
params: &params, MetricsUsername: viper.GetString("METRICS_USERNAME"),
MetricsPassword: viper.GetString("METRICS_PASSWORD"),
log: log,
params: &params,
} }
if s.Debug { if s.Debug {

View File

@ -0,0 +1,34 @@
package handlers
import (
"net/http"
"git.eeqj.de/sneak/gohttpserver/templates"
)
func (s *Handlers) HandleSignupGET() http.HandlerFunc {
t := templates.GetParsed()
return func(w http.ResponseWriter, r *http.Request) {
err := t.ExecuteTemplate(w, "signup.html", nil)
if err != nil {
s.log.Error().Err(err).Msg("")
http.Error(w, http.StatusText(500), 500)
}
}
}
func (s *Handlers) HandleSignupPOST() http.HandlerFunc {
t := templates.GetParsed()
return func(w http.ResponseWriter, r *http.Request) {
_ = r.ParseForm()
err := t.ExecuteTemplate(w, "signup.html", nil)
if err != nil {
s.log.Error().Err(err).Msg("")
http.Error(w, http.StatusText(500), 500)
}
}
}

View File

@ -41,7 +41,6 @@ type ServerParams struct {
type Server struct { type Server struct {
startupTime time.Time startupTime time.Time
port int
exitCode int exitCode int
sentryEnabled bool sentryEnabled bool
log *zerolog.Logger log *zerolog.Logger