Update post move

This commit is contained in:
spsobole 2023-05-23 08:09:57 -06:00
parent 8151a24cc3
commit 97716e7247
11 changed files with 38 additions and 32 deletions

View File

@ -18,8 +18,8 @@ Typical layout for snap servers
package main
import (
"git.thirdmartini.com/pub/snap"
"git.thirdmartini.com/pub/snap/auth"
"git.twelvetwelve.org/library/snap"
"git.twelvetwelve.org/library/snap/auth"
)
func handler(c *snap.Context) {

View File

@ -13,7 +13,7 @@ jobs:
format:
- name: Format source code
type: golang
source: git.thirdmartini.com/pub/snap/...
source: git.twelvetwelve.org/library/snap/...
options:
flags:
@ -22,6 +22,6 @@ jobs:
test:
- name: Running unit tests
type: golang
source: git.thirdmartini.com/pub/snap/...
source: git.twelvetwelve.org/library/snap/...
options:
flags:

View File

@ -8,7 +8,7 @@ import (
"strconv"
"strings"
"git.thirdmartini.com/pub/snap/auth"
"git.twelvetwelve.org/library/snap/auth"
)
type Context struct {

View File

@ -1,8 +1,8 @@
package main
import (
"git.thirdmartini.com/pub/snap"
"git.thirdmartini.com/pub/snap/auth"
"git.twelvetwelve.org/library/snap"
"git.twelvetwelve.org/library/snap/auth"
)
func handler(c *snap.Context) {

12
go.mod
View File

@ -1,9 +1,15 @@
module git.thirdmartini.com/pub/snap
module git.twelvetwelve.org/library/snap
go 1.15
go 1.20
require (
git.thirdmartini.com/pub/fancylog v0.0.0-20180118031448-3f3ebedd6016
github.com/gorilla/mux v1.8.0
github.com/stretchr/testify v1.7.0
)
require (
git.twelvetwelve.org/library/core v0.0.0-20230519041221-8f2da7be661d // indirect
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)

5
go.sum
View File

@ -1,12 +1,11 @@
git.thirdmartini.com/pub/fancylog v0.0.0-20180118031448-3f3ebedd6016 h1:egW0VTyAgD7FjG6iZKHBcHc7siCGjoxm1T71GecYUE4=
git.thirdmartini.com/pub/fancylog v0.0.0-20180118031448-3f3ebedd6016/go.mod h1:nxr8UYB5P+7cpJPpqcbhMjfqm+GH3VDZQs2dFWibA68=
git.twelvetwelve.org/library/core v0.0.0-20230519041221-8f2da7be661d h1:vZy7QM4kcGzbscnY1pSOGNDBDZMmhis/Z+9kZ70gD8Q=
git.twelvetwelve.org/library/core v0.0.0-20230519041221-8f2da7be661d/go.mod h1:QSIAU+Arcx8nd7p4e3hFQIqi50cYf9I0KW9sqxkFnMY=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=

View File

@ -4,7 +4,7 @@ import (
"fmt"
"net/http"
"git.thirdmartini.com/pub/snap/auth"
"git.twelvetwelve.org/library/snap/auth"
)
type RouteBuilder struct {

View File

@ -13,12 +13,12 @@ import (
"strings"
"time"
"git.thirdmartini.com/pub/snap/pkg/autocert"
"git.twelvetwelve.org/library/core/log"
"git.twelvetwelve.org/library/snap/pkg/autocert"
"github.com/gorilla/mux"
"git.thirdmartini.com/pub/fancylog"
"git.thirdmartini.com/pub/snap/auth"
"git.twelvetwelve.org/library/snap/auth"
)
type Server struct {
@ -65,11 +65,11 @@ func (s *Server) makeContext(auth *auth.AuthData, w http.ResponseWriter, r *http
func (s *Server) withLoginHandler(auth auth.Authenticator, loginHandler func(c *Context) bool, handle func(c *Context)) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if s.debug {
log.Debug("authenticated request with login ui handler: ", r.RequestURI)
log.Debugf("authenticated request with login ui handler: %s\n", r.RequestURI)
}
rec, ok := auth.DoAuth(w, r)
if !ok {
log.Debug("authenticated request with login ui handler to login ", r.RequestURI)
log.Debugf("authenticated request with login ui handler to login %s\n", r.RequestURI)
c := s.makeContext(rec, w, r)
if loginHandler(c) {
handle(c)
@ -84,7 +84,7 @@ func (s *Server) withLoginHandler(auth auth.Authenticator, loginHandler func(c *
func (s *Server) authenticated(auth auth.Authenticator, redirect string, handle func(c *Context)) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if s.debug {
log.Debug("authenticated request: ", r.RequestURI)
log.Debugf("authenticated request: %s\n", r.RequestURI)
}
rec, ok := auth.DoAuth(w, r)
@ -104,7 +104,7 @@ func (s *Server) authenticated(auth auth.Authenticator, redirect string, handle
func (s *Server) wrapper(handle func(c *Context)) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if s.debug {
log.Debug("request: ", r.RequestURI)
log.Debugf("request: %s", r.RequestURI)
}
c := s.makeContext(nil, w, r)
@ -121,6 +121,7 @@ func (s *Server) wrapper(handle func(c *Context)) http.HandlerFunc {
}
// This is a bit different then the standard template.parseFiles code in that it gives us hiarchial templates
//
// header.html
// mydirectory/service.html ...
func (s *Server) parseTemplates(t *template.Template, filenames ...string) (*template.Template, error) {
@ -206,7 +207,7 @@ func (s *Server) LoadTemplatesFS(fs http.FileSystem, base string) (*template.Tem
if strings.Contains(path, ".html") {
_, err := s.parseTemplates(tmpl, path)
if err != nil {
log.Println(err)
log.Printf("%+v\n", err)
}
}
return err
@ -222,7 +223,7 @@ func (s *Server) LoadTemplatesFS(fs http.FileSystem, base string) (*template.Tem
func (s *Server) loadTemplates() *template.Template {
tmpl, err := s.LoadTemplatesFS(s.fs, s.templates)
if err != nil {
log.Fatal("loadTemplates", err, s.templates)
log.Fatalf("loadTemplates %v %v\n", err, s.templates)
}
return tmpl
}
@ -249,7 +250,7 @@ func (s *Server) render(w http.ResponseWriter, tmpl string, content interface{})
}
err := s.getTemplates().ExecuteTemplate(w, tmpl, content)
if err != nil {
log.Warn(err)
log.Warnf("%s\n", err)
}
}
@ -279,7 +280,7 @@ func (s *Server) HandleFuncAuthenticatedWithLogin(path string, loginHandler func
func (s *Server) HandleFuncCustomAuth(auth auth.Authenticator, path, redirect string, f func(c *Context)) *mux.Route {
if auth == nil {
log.Warn("Nil auth on", path)
log.Warnf("Nil auth on %s\n", path)
return nil
}
return s.router.HandleFunc(path, s.authenticated(auth, redirect, f))
@ -315,7 +316,7 @@ func (s *Server) Router() *mux.Router {
func (s *Server) ServeTLS(keyPath string, certPath string) error {
kpr, err := autocert.NewManager(certPath, keyPath)
if err != nil {
log.Fatal(err)
log.Fatalf("%v\n", err)
}
srv := &http.Server{

View File

@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/assert"
"git.thirdmartini.com/pub/snap/auth"
"git.twelvetwelve.org/library/snap/auth"
)
var rootExpected = []byte(`