diff --git a/config/config.go b/config/config.go
index 2962154..a301e12 100644
--- a/config/config.go
+++ b/config/config.go
@@ -15,14 +15,16 @@ const Prefix = "vanity"
// Configures the vanityd server from the environment.
type Config struct {
- Maintenance bool `default:"false" desc:"if true, the server will start in maintenance mode"`
- LogLevel logger.LevelDecoder `split_words:"true" default:"info" desc:"specify the verbosity of logging (trace, debug, info, warn, error, fatal panic)"`
- ConsoleLog bool `split_words:"true" default:"false" desc:"if true logs colorized human readable output instead of json"`
- BindAddr string `split_words:"true" default:":3264" desc:"the ip address and port to bind the server on"`
- ReadTimeout time.Duration `split_words:"true" default:"20s" desc:"amount of time allowed to read request headers before server decides the request is too slow"`
- WriteTimeout time.Duration `split_words:"true" default:"20s" desc:"maximum amount of time before timing out a write to a response"`
- IdleTimeout time.Duration `split_words:"true" default:"10m" desc:"maximum amount of time to wait for the next request while keep alives are enabled"`
- processed bool
+ Maintenance bool `default:"false" desc:"if true, the server will start in maintenance mode"`
+ Domain string `default:"" desc:"specify the domain of the vanity URLs, otherwise the request host will be used"`
+ DefaultBranch string `split_words:"true" default:"main" desc:"specify the default branch to use for repository references"`
+ LogLevel logger.LevelDecoder `split_words:"true" default:"info" desc:"specify the verbosity of logging (trace, debug, info, warn, error, fatal panic)"`
+ ConsoleLog bool `split_words:"true" default:"false" desc:"if true logs colorized human readable output instead of json"`
+ BindAddr string `split_words:"true" default:":3264" desc:"the ip address and port to bind the server on"`
+ ReadTimeout time.Duration `split_words:"true" default:"20s" desc:"amount of time allowed to read request headers before server decides the request is too slow"`
+ WriteTimeout time.Duration `split_words:"true" default:"20s" desc:"maximum amount of time before timing out a write to a response"`
+ IdleTimeout time.Duration `split_words:"true" default:"10m" desc:"maximum amount of time to wait for the next request while keep alives are enabled"`
+ processed bool
}
func New() (conf Config, err error) {
diff --git a/errors.go b/errors.go
new file mode 100644
index 0000000..e3fddfc
--- /dev/null
+++ b/errors.go
@@ -0,0 +1,9 @@
+package vanity
+
+import "errors"
+
+var (
+ ErrNoRepository = errors.New("a repository url is required")
+ ErrInvalidRepository = errors.New("expected repository url in the form vcsScheme://vcsHost/user/repo")
+ ErrInvalidProtocol = errors.New("protocol must be git, github, or gogs")
+)
diff --git a/logger/middleware.go b/logger/middleware.go
index 0c9c877..6942958 100644
--- a/logger/middleware.go
+++ b/logger/middleware.go
@@ -5,13 +5,11 @@ import (
"time"
"github.com/julienschmidt/httprouter"
- "github.com/rotationalio/vanity"
"github.com/rotationalio/vanity/server/middleware"
"github.com/rs/zerolog/log"
)
-func HTTPLogger(server string) middleware.Middleware {
- version := vanity.Version()
+func HTTPLogger(server, version string) middleware.Middleware {
return func(next httprouter.Handle) httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
// Before the request
diff --git a/server/routes.go b/server/routes.go
index 7c9c18d..52d6e4c 100644
--- a/server/routes.go
+++ b/server/routes.go
@@ -5,6 +5,7 @@ import (
"net/http"
"github.com/julienschmidt/httprouter"
+ "github.com/rotationalio/vanity"
"github.com/rotationalio/vanity/logger"
"github.com/rotationalio/vanity/server/middleware"
)
@@ -12,7 +13,7 @@ import (
// Sets up the server's middleware and routes.
func (s *Server) setupRoutes() (err error) {
middleware := []middleware.Middleware{
- logger.HTTPLogger("vanity"),
+ logger.HTTPLogger("vanity", vanity.Version()),
s.Maintenance(),
}
@@ -31,6 +32,10 @@ func (s *Server) setupRoutes() (err error) {
s.addRoute(http.MethodGet, "/", s.HomePage(), middleware...)
// Golang Vanity Handling
+ pkg := &vanity.GoPackage{Domain: "go.rotational.io", Repository: "https://github.com/rotationalio/confire"}
+ pkg.Resolve(nil)
+ s.addRoute(http.MethodGet, "/rotationalio/confire", Vanity(pkg), middleware...)
+ s.addRoute(http.MethodGet, "/rotationalio/confire/*filepath", Vanity(pkg), middleware...)
return nil
}
diff --git a/server/static/css/style.css b/server/static/css/style.css
index 778208e..82184f5 100644
--- a/server/static/css/style.css
+++ b/server/static/css/style.css
@@ -34,4 +34,8 @@ header div {
padding: 24px;
margin: 0;
font-size: 24px;
+}
+
+.redirect {
+ padding: 32px 0;
}
\ No newline at end of file
diff --git a/server/templates/vanity.html b/server/templates/vanity.html
new file mode 100644
index 0000000..3ad018c
--- /dev/null
+++ b/server/templates/vanity.html
@@ -0,0 +1,23 @@
+
+
+