refactor: move packages into a more sensible structure
This commit is contained in:
parent
66d92df040
commit
03eccdadeb
@ -1,12 +1,12 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"git.markbailey.dev/cerbervs/ptpp/app/session"
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/logger"
|
||||
"net/http"
|
||||
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/database"
|
||||
werror "git.markbailey.dev/cerbervs/ptpp/lib/error"
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/session"
|
||||
)
|
||||
|
||||
type IController interface {
|
||||
|
@ -3,11 +3,11 @@ package routing
|
||||
import (
|
||||
"git.markbailey.dev/cerbervs/ptpp/app/controller"
|
||||
"git.markbailey.dev/cerbervs/ptpp/app/handler"
|
||||
"git.markbailey.dev/cerbervs/ptpp/app/session"
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/database"
|
||||
werror "git.markbailey.dev/cerbervs/ptpp/lib/error"
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/logger"
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/middleware"
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/session"
|
||||
"git.markbailey.dev/cerbervs/ptpp/util"
|
||||
"log"
|
||||
"net/http"
|
||||
|
@ -29,4 +29,5 @@ var AppRouter = Router{
|
||||
Middleware: &[]middleware.Func{middleware.WithAuth},
|
||||
},
|
||||
},
|
||||
Middleware: &[]middleware.Func{middleware.WithLogger, middleware.WithUsername},
|
||||
}
|
||||
|
1
app/session/cookieprovider.go
Normal file
1
app/session/cookieprovider.go
Normal file
@ -0,0 +1 @@
|
||||
package session
|
@ -1,11 +1,9 @@
|
||||
package memory
|
||||
package session
|
||||
|
||||
import (
|
||||
"container/list"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/session"
|
||||
)
|
||||
|
||||
var prov = &Provider{list: list.New()}
|
||||
@ -58,7 +56,7 @@ type Provider struct {
|
||||
lock sync.Mutex
|
||||
}
|
||||
|
||||
func (p *Provider) SessionInit(sid string) (session.ISession, error) {
|
||||
func (p *Provider) SessionInit(sid string) (ISession, error) {
|
||||
prov.lock.Lock()
|
||||
defer prov.lock.Unlock()
|
||||
v := make(map[interface{}]interface{}, 0)
|
||||
@ -68,7 +66,7 @@ func (p *Provider) SessionInit(sid string) (session.ISession, error) {
|
||||
return newSess, nil
|
||||
}
|
||||
|
||||
func (p *Provider) SessionRead(sid string) (session.ISession, error) {
|
||||
func (p *Provider) SessionRead(sid string) (ISession, error) {
|
||||
if element, ok := prov.sessions[sid]; ok {
|
||||
return element.Value.(*MemSessionStore), nil
|
||||
}
|
||||
@ -119,5 +117,5 @@ func (p *Provider) SessionUpdate(sid string) error {
|
||||
|
||||
func init() {
|
||||
prov.sessions = make(map[string]*list.Element, 0)
|
||||
session.Register("memory", prov)
|
||||
Register("memory", prov)
|
||||
}
|
@ -3,13 +3,13 @@ package main
|
||||
import (
|
||||
"git.markbailey.dev/cerbervs/ptpp/app"
|
||||
"git.markbailey.dev/cerbervs/ptpp/app/routing"
|
||||
main2 "git.markbailey.dev/cerbervs/ptpp/app/server"
|
||||
"git.markbailey.dev/cerbervs/ptpp/app/server"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
_ "git.markbailey.dev/cerbervs/ptpp/lib/session/memory"
|
||||
_ "git.markbailey.dev/cerbervs/ptpp/app/session"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -31,7 +31,7 @@ func main() {
|
||||
port = devPort
|
||||
}
|
||||
|
||||
s := main2.Server{
|
||||
s := server.Server{
|
||||
Addr: addr,
|
||||
Server: http.Server{
|
||||
Addr: addr + ":" + strconv.Itoa(port),
|
||||
|
@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"git.markbailey.dev/cerbervs/ptpp/app/controller"
|
||||
"git.markbailey.dev/cerbervs/ptpp/app/session"
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/database"
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/logger"
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/session"
|
||||
"git.markbailey.dev/cerbervs/ptpp/view/layout"
|
||||
"net/http"
|
||||
|
||||
|
@ -3,9 +3,9 @@ package shared
|
||||
import (
|
||||
"context"
|
||||
"git.markbailey.dev/cerbervs/ptpp/app/controller"
|
||||
"git.markbailey.dev/cerbervs/ptpp/app/session"
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/database"
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/logger"
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/session"
|
||||
"git.markbailey.dev/cerbervs/ptpp/view/layout"
|
||||
"net/http"
|
||||
"os"
|
||||
|
@ -4,10 +4,10 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"git.markbailey.dev/cerbervs/ptpp/app/controller"
|
||||
"git.markbailey.dev/cerbervs/ptpp/app/session"
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/database"
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/database/dto"
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/logger"
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/session"
|
||||
"git.markbailey.dev/cerbervs/ptpp/util"
|
||||
"net/http"
|
||||
"time"
|
||||
|
@ -2,12 +2,12 @@ package middleware
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.markbailey.dev/cerbervs/ptpp/app/session"
|
||||
"git.markbailey.dev/cerbervs/ptpp/util"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/logger"
|
||||
"git.markbailey.dev/cerbervs/ptpp/lib/session"
|
||||
)
|
||||
|
||||
type Func func(http.Handler) http.Handler
|
||||
|
@ -1 +0,0 @@
|
||||
package memory
|
Loading…
x
Reference in New Issue
Block a user