removed 'internal' directory
This commit is contained in:
parent
8c200a5a6c
commit
65709049d7
42 changed files with 35 additions and 44 deletions
|
|
@ -6,8 +6,8 @@ import (
|
|||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/Bronku/iroon/internal/models"
|
||||
"github.com/Bronku/iroon/internal/store"
|
||||
"github.com/Bronku/iroon/models"
|
||||
"github.com/Bronku/iroon/store"
|
||||
)
|
||||
|
||||
type Authenticator struct {
|
||||
|
|
@ -3,7 +3,7 @@ package auth
|
|||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/Bronku/iroon/internal/crypto"
|
||||
"github.com/Bronku/iroon/crypto"
|
||||
)
|
||||
|
||||
func (a *Authenticator) verifyCredentials(login, password string) error {
|
||||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/Bronku/iroon/internal/models"
|
||||
"github.com/Bronku/iroon/models"
|
||||
)
|
||||
|
||||
func (a *Authenticator) getSession(r *http.Request) (models.Token, error) {
|
||||
|
|
@ -4,8 +4,8 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/Bronku/iroon/internal/crypto"
|
||||
"github.com/Bronku/iroon/internal/models"
|
||||
"github.com/Bronku/iroon/crypto"
|
||||
"github.com/Bronku/iroon/models"
|
||||
)
|
||||
|
||||
func (a *Authenticator) newSession(user string) (http.Cookie, error) {
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
package iroon
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/Bronku/iroon/internal/auth"
|
||||
"github.com/Bronku/iroon/internal/logging"
|
||||
"github.com/Bronku/iroon/internal/server"
|
||||
"github.com/Bronku/iroon/internal/store"
|
||||
)
|
||||
|
||||
func Run() {
|
||||
s := store.OpenStore("./foo.db")
|
||||
s.AddUser("admin", "secret")
|
||||
defer s.Close()
|
||||
h := server.New(s)
|
||||
defer h.Close()
|
||||
|
||||
var handler http.Handler = h
|
||||
handler = logging.Middleware(handler)
|
||||
handler = auth.New(s).Middleware(handler)
|
||||
fmt.Println("starting server")
|
||||
log.Fatal(http.ListenAndServe(":8080", handler))
|
||||
}
|
||||
21
main.go
21
main.go
|
|
@ -1,9 +1,26 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/Bronku/iroon/cmd/iroon"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/Bronku/iroon/auth"
|
||||
"github.com/Bronku/iroon/logging"
|
||||
"github.com/Bronku/iroon/server"
|
||||
"github.com/Bronku/iroon/store"
|
||||
)
|
||||
|
||||
func main() {
|
||||
iroon.Run()
|
||||
s := store.OpenStore("./foo.db")
|
||||
s.AddUser("admin", "secret")
|
||||
defer s.Close()
|
||||
h := server.New(s)
|
||||
defer h.Close()
|
||||
|
||||
var handler http.Handler = h
|
||||
handler = logging.Middleware(handler)
|
||||
handler = auth.New(s).Middleware(handler)
|
||||
fmt.Println("starting server")
|
||||
log.Fatal(http.ListenAndServe(":8080", handler))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Bronku/iroon/internal/models"
|
||||
"github.com/Bronku/iroon/models"
|
||||
)
|
||||
|
||||
func monthInterval(y int, m time.Month) (firstDay, lastDay time.Time) {
|
||||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Bronku/iroon/internal/models"
|
||||
"github.com/Bronku/iroon/models"
|
||||
)
|
||||
|
||||
func (h *Server) postCake(r *http.Request) (any, int, error) {
|
||||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"html/template"
|
||||
"net/http"
|
||||
|
||||
"github.com/Bronku/iroon/internal/store"
|
||||
"github.com/Bronku/iroon/store"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/Bronku/iroon/internal/logging"
|
||||
"github.com/Bronku/iroon/logging"
|
||||
)
|
||||
|
||||
//go:embed templates/*
|
||||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/Bronku/iroon/internal/models"
|
||||
"github.com/Bronku/iroon/models"
|
||||
)
|
||||
|
||||
func (s *Store) cakeCount() int {
|
||||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/Bronku/iroon/internal/models"
|
||||
"github.com/Bronku/iroon/models"
|
||||
)
|
||||
|
||||
// #todo update labels in templates
|
||||
|
|
@ -3,7 +3,7 @@ package store
|
|||
import (
|
||||
"time"
|
||||
|
||||
"github.com/Bronku/iroon/internal/models"
|
||||
"github.com/Bronku/iroon/models"
|
||||
)
|
||||
|
||||
func (s *Store) AddSession(token, userName string, expiration time.Time) error {
|
||||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"database/sql"
|
||||
"log"
|
||||
|
||||
"github.com/Bronku/iroon/internal/models"
|
||||
"github.com/Bronku/iroon/models"
|
||||
_ "github.com/knaka/go-sqlite3-fts5"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
|
@ -3,8 +3,8 @@ package store
|
|||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/Bronku/iroon/internal/crypto"
|
||||
"github.com/Bronku/iroon/internal/models"
|
||||
"github.com/Bronku/iroon/crypto"
|
||||
"github.com/Bronku/iroon/models"
|
||||
)
|
||||
|
||||
func (s *Store) AddUser(login, password string) error {
|
||||
Loading…
Add table
Add a link
Reference in a new issue