diff options
| author | tjpcc <tjp@ctrl-c.club> | 2023-09-28 08:08:48 -0600 |
|---|---|---|
| committer | tjpcc <tjp@ctrl-c.club> | 2023-10-09 08:47:37 -0600 |
| commit | 6e1c25af361dde4c063eccbf769e966df4b65f23 (patch) | |
| tree | d28044cf2db246555deda8db395f2f0a7e786590 /types.go | |
| parent | b4f45f7c654e87bda6d5e7effb6ac5b5feb29ce0 (diff) | |
config file refactor
Diffstat (limited to 'types.go')
| -rw-r--r-- | types.go | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/types.go b/types.go new file mode 100644 index 0000000..8d010b2 --- /dev/null +++ b/types.go @@ -0,0 +1,66 @@ +package main + +import ( + "context" + "crypto/tls" + "net" + "os/user" + + "github.com/go-kit/log/level" + "tildegit.org/tjp/sliderule" +) + +type Modifiers struct { + DirDefault string + DirList bool + Exec bool + ExtendedGophermap bool + AutoAtom bool + Titan *Auth + + titanName string +} + +func (m Modifiers) Empty() bool { + return m.DirDefault == "" && !m.DirList && !m.Exec && !m.ExtendedGophermap +} + +type RouteDirective struct { + // Allowed: "static", "cgi", "git", "titan" + Type string + + // "<FsPath> at <URLPath>" + FsPath string + URLPath string + + // "with ..." + Modifiers Modifiers + + Auth *Auth + authName string +} + +type Server struct { + Type string + IP net.IP + Port uint16 + TLS *tls.Config + Hostnames []string + Routes []RouteDirective +} + +type Auth struct { + Name string + Strategy AuthStrategy +} + +type AuthStrategy interface { + Approve(context.Context, *sliderule.Request) bool +} + +type Configuration struct { + SystemUser *user.User + LogLevel level.Value + + Servers []Server +} |
