split client and golang api into separate repos

This commit is contained in:
Landon Dyck 2021-11-26 16:08:14 -06:00
parent b92a6e0676
commit 4d6276db74
21 changed files with 24 additions and 1087 deletions

3
.gitignore vendored
View File

@ -13,6 +13,5 @@
*.log
mouseion
mouseion_client
server
*.db

1
client/.gitignore vendored
View File

@ -1 +0,0 @@
client

View File

@ -1,220 +0,0 @@
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"strings"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
)
type success struct{}
type accountMenu struct {
cursor int
choices []string
}
func account() accountMenu {
return accountMenu{
choices: []string{"Change Email", "API Tokens"},
}
}
func (m accountMenu) Init() tea.Cmd {
return nil
}
func (m accountMenu) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case "esc":
return home(), nil
case "ctrl+c", "q":
return m, tea.Quit
case "up", "k":
if m.cursor > 0 {
m.cursor--
}
case "down", "j":
if m.cursor < len(m.choices)-1 {
m.cursor++
}
case "enter", " ":
switch m.cursor {
case 0:
return changeEmail(), nil
case 1:
menu := APITokenMenu()
return menu, menu.Init()
}
}
}
return m, nil
}
func (m accountMenu) View() string {
b := &strings.Builder{}
b.WriteString(titleStyle.Render("Account Management"))
b.WriteString("\n\n")
for i, choice := range m.choices {
cursor := " "
if m.cursor == i {
cursor = ">"
}
fmt.Fprintf(b, "%s %s\n", cursor, choice)
}
fmt.Fprint(b, "\nPress q to quit.\n")
return b.String()
}
type titledInput struct {
Title string
textinput.Model
}
type changeEmailForm struct {
focusIndex int
inputs []titledInput
}
func changeEmail() changeEmailForm {
s := changeEmailForm{inputs: make([]titledInput, 1)}
for i := range s.inputs {
t := titledInput{}
t.Model = textinput.NewModel()
t.CursorStyle = cursorStyle
t.CharLimit = 0
t.SetCursorMode(textinput.CursorStatic)
switch i {
case 0:
t.Title = "New Email"
t.Placeholder = "mouseion@example.com"
t.Focus()
t.PromptStyle = focusedStyle
t.TextStyle = focusedStyle
}
s.inputs[i] = t
}
return s
}
func (form changeEmailForm) Init() tea.Cmd {
return nil
}
func (form changeEmailForm) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case "ctrl+c", "q":
return form, tea.Quit
case "esc":
return account(), nil
case "tab", "shift+tab", "enter", "up", "down":
s := msg.String()
if s == "enter" && form.focusIndex == len(form.inputs) {
return form, form.updateEmail
}
if s == "up" || s == "shift+tab" {
form.focusIndex--
} else {
form.focusIndex++
}
if form.focusIndex > len(form.inputs) {
form.focusIndex = 0
} else if form.focusIndex < 0 {
form.focusIndex = len(form.inputs)
}
cmds := make([]tea.Cmd, len(form.inputs))
for i := 0; i <= len(form.inputs)-1; i++ {
if i == form.focusIndex {
cmds[i] = form.inputs[i].Focus()
form.inputs[i].PromptStyle = focusedStyle
form.inputs[i].TextStyle = focusedStyle
continue
}
form.inputs[i].Blur()
form.inputs[i].PromptStyle = noStyle
form.inputs[i].TextStyle = noStyle
}
return form, tea.Batch(cmds...)
}
case success:
return account(), nil
}
return form, form.updateInputs(msg)
}
func (form *changeEmailForm) updateInputs(msg tea.Msg) tea.Cmd {
var cmds = make([]tea.Cmd, len(form.inputs))
for i := range form.inputs {
form.inputs[i].Model, cmds[i] = form.inputs[i].Update(msg)
}
return tea.Batch(cmds...)
}
func (form changeEmailForm) View() string {
var b strings.Builder
b.WriteString(titleStyle.Render("Account Management"))
b.WriteString("\n\n")
for i := range form.inputs {
b.WriteString(form.inputs[i].Title)
b.WriteRune(' ')
b.WriteString(form.inputs[i].View())
if i < len(form.inputs)-1 {
b.WriteRune('\n')
}
}
buttonStyle := &blurredStyle
if form.focusIndex == len(form.inputs) {
buttonStyle = &focusedStyle
}
fmt.Fprintf(&b, "\n\n%s\n\n", buttonStyle.Render(submitButtonText))
return b.String()
}
type changeEmailCommand struct {
Email string `json:"email"`
}
func (form changeEmailForm) updateEmail() tea.Msg {
cmd := changeEmailCommand{
Email: form.inputs[0].Value(),
}
buf := bytes.NewBuffer(nil)
encoder := json.NewEncoder(buf)
err := encoder.Encode(cmd)
if err != nil {
return err
}
resp, err := httpClient.Post("http://localhost:8069/account/change_email", contentTypeJSON, buf)
if err != nil {
return err
}
if resp.StatusCode == http.StatusOK {
return success{}
}
//TODO: Handle Errors
return nil
}

View File

@ -1,174 +0,0 @@
package main
import (
"encoding/json"
"fmt"
"net/http"
"strings"
tea "github.com/charmbracelet/bubbletea"
)
type apiTokenMenu struct {
cursor int
choices []interface{}
}
type deletedID string
const createNewTokenText = "Create New Token"
func APITokenMenu() apiTokenMenu {
return apiTokenMenu{
choices: []interface{}{createNewTokenText},
}
}
func (m apiTokenMenu) Init() tea.Cmd {
return m.listTokens
}
func (m apiTokenMenu) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case "esc":
return account(), nil
case "ctrl+c", "q":
return m, tea.Quit
case "up", "k":
if m.cursor > 0 {
m.cursor--
}
case "down", "j":
if m.cursor < len(m.choices)-1 {
m.cursor++
}
case "enter", " ":
if m.cursor == len(m.choices)-1 {
return m, m.createToken
}
case "ctrl+d":
if m.cursor < len(m.choices)-1 {
token, ok := m.choices[m.cursor].(apiToken)
if !ok {
return m, nil
}
return m, m.deleteToken(token)
}
}
case apiToken:
m.choices[len(m.choices)-1] = msg
m.choices = append(m.choices, createNewTokenText)
return m, nil
case []apiToken:
if len(msg) == 0 {
return m, nil
}
newChoices := make([]interface{}, 0, len(msg)+1)
for _, token := range msg {
newChoices = append(newChoices, token)
}
newChoices = append(newChoices, createNewTokenText)
m.choices = newChoices
return m, nil
case deletedID:
newChoices := make([]interface{}, 0, len(m.choices)-1)
for _, choice := range m.choices {
token, ok := choice.(apiToken)
if ok && token.ID == string(msg) {
continue
}
newChoices = append(newChoices, choice)
}
m.choices = newChoices
return m, nil
}
return m, nil
}
func (m apiTokenMenu) View() string {
b := &strings.Builder{}
b.WriteString(titleStyle.Render("API Tokens"))
b.WriteString("\n\n")
for i, choice := range m.choices {
cursor := " "
if m.cursor == i {
cursor = ">"
}
switch choice := choice.(type) {
case apiToken:
fmt.Fprintf(b, "%s ID: %s\n", cursor, choice.ID)
if choice.Secret != "" {
fmt.Fprintf(b, "\tSecret: %s\n", choice.Secret)
}
default:
fmt.Fprintf(b, "%s %s\n", cursor, choice)
}
}
fmt.Fprint(b, "\nPress ctrl+d to delete a token.")
fmt.Fprint(b, "\nPress q to quit.\n")
return b.String()
}
type apiToken struct {
ID string `json:"id"`
Secret string `json:"secret"`
}
func (m apiTokenMenu) createToken() tea.Msg {
resp, err := httpClient.Post("http://localhost:8069/auth/api_token", contentTypeJSON, nil)
if err != nil {
return err
}
defer resp.Body.Close()
decoder := json.NewDecoder(resp.Body)
token := apiToken{}
err = decoder.Decode(&token)
if err != nil {
return err
}
return token
}
type listTokensResponse struct {
Tokens []apiToken `json:"tokens"`
}
func (m apiTokenMenu) listTokens() tea.Msg {
resp, err := httpClient.Get("http://localhost:8069/auth/api_token")
if err != nil {
return err
}
defer resp.Body.Close()
decoder := json.NewDecoder(resp.Body)
listResponse := listTokensResponse{}
err = decoder.Decode(&listResponse)
if err != nil {
return err
}
return listResponse.Tokens
}
func (m apiTokenMenu) deleteToken(token apiToken) tea.Cmd {
return func() tea.Msg {
req, err := http.NewRequest(http.MethodDelete, fmt.Sprintf("http://localhost:8069/auth/api_token?id=%s", token.ID), nil)
if err != nil {
return err
}
resp, err := httpClient.Do(req)
if err != nil {
return err
}
if resp.StatusCode != 200 {
return nil
}
return deletedID(token.ID)
}
}

View File

@ -1,167 +0,0 @@
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"strings"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
)
type loginForm struct {
focusIndex int
inputs []titledInput
}
func login() loginForm {
s := loginForm{
inputs: make([]titledInput, 2),
}
for i := range s.inputs {
var t titledInput
t.Model = textinput.NewModel()
t.CursorStyle = cursorStyle
t.SetCursorMode(textinput.CursorStatic)
switch i {
case 0:
t.Title = "Email"
t.Placeholder = "mouseion@example.com"
t.Focus()
t.PromptStyle = focusedStyle
t.TextStyle = focusedStyle
case 1:
t.Title = "Password"
t.Placeholder = "Password"
t.EchoMode = textinput.EchoPassword
t.EchoCharacter = '*'
}
s.inputs[i] = t
}
return s
}
func (s loginForm) Init() tea.Cmd {
return nil
}
func (m loginForm) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case "ctrl+c", "q":
return m, tea.Quit
case "esc":
return home(), nil
case "tab", "shift+tab", "enter", "up", "down":
s := msg.String()
if s == "enter" {
if m.focusIndex == len(m.inputs) {
return m, m.login
}
if m.focusIndex == len(m.inputs)+1 {
return m, m.register
}
}
if s == "up" || s == "shift+tab" {
m.focusIndex--
} else {
m.focusIndex++
}
if m.focusIndex > len(m.inputs)+1 {
m.focusIndex = 0
} else if m.focusIndex < 0 {
m.focusIndex = len(m.inputs) + 1
}
cmds := make([]tea.Cmd, len(m.inputs))
for i := 0; i <= len(m.inputs)-1; i++ {
if i == m.focusIndex {
cmds[i] = m.inputs[i].Focus()
m.inputs[i].PromptStyle = focusedStyle
m.inputs[i].TextStyle = focusedStyle
continue
}
m.inputs[i].Blur()
m.inputs[i].PromptStyle = noStyle
m.inputs[i].TextStyle = noStyle
}
return m, tea.Batch(cmds...)
}
case success:
return initialModel(true), nil
}
return m, m.updateInputs(msg)
}
func (s *loginForm) updateInputs(msg tea.Msg) tea.Cmd {
var cmds = make([]tea.Cmd, len(s.inputs))
for i := range s.inputs {
s.inputs[i].Model, cmds[i] = s.inputs[i].Update(msg)
}
return tea.Batch(cmds...)
}
func (s loginForm) View() string {
var b strings.Builder
for i := range s.inputs {
b.WriteString(s.inputs[i].View())
if i < len(s.inputs)-1 {
b.WriteRune('\n')
}
}
buttonStyle := &blurredStyle
if s.focusIndex == len(s.inputs) {
buttonStyle = &focusedStyle
}
fmt.Fprintf(&b, "\n\n%s\n", buttonStyle.Render(loginButtonText))
buttonStyle = &blurredStyle
if s.focusIndex == len(s.inputs)+1 {
buttonStyle = &focusedStyle
}
fmt.Fprintf(&b, "\n%s\n\n", buttonStyle.Render(registerButtonText))
return b.String()
}
func (m loginForm) login() tea.Msg {
loginCmd := map[string]string{}
loginCmd["email"], loginCmd["password"] = m.inputs[0].Value(), m.inputs[1].Value()
b := bytes.NewBuffer(nil)
encoder := json.NewEncoder(b)
err := encoder.Encode(loginCmd)
if err != nil {
return err
}
response, err := httpClient.Post("http://localhost:8069/auth/login", contentTypeJSON, b)
if err != nil {
return err
}
defer response.Body.Close()
if response.StatusCode != 307 {
body, err := io.ReadAll(response.Body)
if err != nil {
return err
}
return body
}
return success{}
}
func (m loginForm) register() tea.Msg {
return success{}
}

View File

@ -1,126 +0,0 @@
package main
import (
"fmt"
"log"
"net/http"
"net/http/cookiejar"
"os"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"golang.org/x/net/publicsuffix"
)
const (
contentTypeJSON = "application/json"
loginButtonText = "[ Login ]"
registerButtonText = "[ Register ]"
submitButtonText = "[ Submit ]"
)
var (
titleStyle = lipgloss.NewStyle().Bold(true)
focusedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))
blurredStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("240"))
cursorStyle = focusedStyle.Copy()
noStyle = lipgloss.NewStyle()
docStyle = lipgloss.NewStyle().Margin(vertMargin, horizMargin)
)
var (
httpClient *http.Client
)
func initialModel(loggedIn bool) tea.Model {
if !loggedIn {
return login()
}
return home()
}
type mainMenu struct {
choices []string
cursor int
windowSize [2]int
}
func home() mainMenu {
return mainMenu{
choices: []string{
"Search log entries",
"Account Management",
},
windowSize: [2]int{0, 0},
}
}
func (m mainMenu) Init() tea.Cmd {
return nil
}
func (m mainMenu) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case "ctrl+c", "q":
return m, tea.Quit
case "up", "k":
if m.cursor > 0 {
m.cursor--
}
case "down", "j":
if m.cursor < len(m.choices)-1 {
m.cursor++
}
case "enter", " ":
switch m.cursor {
case 0:
return search(m.windowSize[0], m.windowSize[1]), nil
case 1:
return account(), nil
}
}
case tea.WindowSizeMsg:
m.windowSize = [2]int{msg.Width, msg.Height}
}
return m, nil
}
func (m mainMenu) View() string {
s := "What do you want to do?\n\n"
for i, choice := range m.choices {
cursor := " "
if m.cursor == i {
cursor = ">"
}
s += fmt.Sprintf("%s %s\n", cursor, choice)
}
s += "\nPress q to quit.\n"
return s
}
func main() {
cookieJar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
httpClient = &http.Client{Jar: cookieJar}
if err != nil {
log.Println(err)
return
}
var loggedIn bool
defer func() {
r := recover()
if r != nil {
log.Println(r)
}
}()
p := tea.NewProgram(initialModel(loggedIn), tea.WithAltScreen())
if err := p.Start(); err != nil {
fmt.Printf("Alas, there's been an error: %v", err)
os.Exit(1)
}
}

View File

@ -1,231 +0,0 @@
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"strings"
"time"
"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/codemonkeysoftware/mouseion/pkg/entry"
)
const (
vertMargin = 1
horizMargin = 2
)
type item struct {
entry.LogEntry
}
func (i item) Title() string { return fmt.Sprintf("%s: %s", i.Timestamp.Format(time.RFC3339), i.Text) }
func (i item) Description() string { return strings.Join(i.Tags, ",") }
func (i item) FilterValue() string { return i.Text }
type searchMenu struct {
showResult bool
focusIndex int
inputs []textinput.Model
list list.Model
}
func search(width, height int) searchMenu {
s := searchMenu{
inputs: make([]textinput.Model, 3),
list: list.NewModel(nil, list.NewDefaultDelegate(), width-(2*horizMargin), height-(2*vertMargin)),
}
s.list.Title = "Found Log Entries:"
var t textinput.Model
for i := range s.inputs {
t = textinput.NewModel()
t.CursorStyle = cursorStyle
t.CharLimit = 20
t.SetCursorMode(textinput.CursorStatic)
switch i {
case 0:
t.Placeholder = "Start (2021-06-01T11:22:33Z)"
t.Focus()
t.PromptStyle = focusedStyle
t.TextStyle = focusedStyle
case 1:
t.Placeholder = "Start (2021-06-01T11:22:33Z)"
case 2:
t.Placeholder = "Tags (comma separated)"
t.CharLimit = 0
}
s.inputs[i] = t
}
return s
}
func (s searchMenu) Init() tea.Cmd {
return nil
}
func (m searchMenu) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case "ctrl+c", "q":
return m, tea.Quit
case "esc":
if !m.showResult {
return home(), nil
}
m.showResult = false
return m, nil
case "tab", "shift+tab", "enter", "up", "down":
if m.showResult {
break
}
s := msg.String()
if s == "enter" && m.focusIndex == len(m.inputs) {
return m, m.getEntries
}
if s == "up" || s == "shift+tab" {
m.focusIndex--
} else {
m.focusIndex++
}
if m.focusIndex > len(m.inputs) {
m.focusIndex = 0
} else if m.focusIndex < 0 {
m.focusIndex = len(m.inputs)
}
cmds := make([]tea.Cmd, len(m.inputs))
for i := 0; i <= len(m.inputs)-1; i++ {
if i == m.focusIndex {
cmds[i] = m.inputs[i].Focus()
m.inputs[i].PromptStyle = focusedStyle
m.inputs[i].TextStyle = focusedStyle
continue
}
m.inputs[i].Blur()
m.inputs[i].PromptStyle = noStyle
m.inputs[i].TextStyle = noStyle
}
return m, tea.Batch(cmds...)
}
case []entry.LogEntry:
cmd := m.loadEntries(msg)
m.list.SetFilteringEnabled(false)
m.showResult = true
return m, cmd
case tea.WindowSizeMsg:
top, right, bottom, left := docStyle.GetMargin()
m.list.SetSize(msg.Width-left-right, msg.Height-top-bottom)
}
if m.showResult {
var cmd tea.Cmd
m.list, cmd = m.list.Update(msg)
return m, cmd
}
return m, m.updateInputs(msg)
}
func (s *searchMenu) updateInputs(msg tea.Msg) tea.Cmd {
var cmds = make([]tea.Cmd, len(s.inputs))
for i := range s.inputs {
s.inputs[i], cmds[i] = s.inputs[i].Update(msg)
}
return tea.Batch(cmds...)
}
func (s *searchMenu) getEntries() tea.Msg {
//TODO: add input validation
c := &http.Client{Timeout: 60 * time.Second}
u, err := url.Parse("http://localhost:8069/client/get_entries")
if err != nil {
return err
}
start := s.inputs[0].Value()
end := s.inputs[1].Value()
tags := s.inputs[2].Value()
q := u.Query()
if start != "" {
q.Add("start", start)
}
if end != "" {
q.Add("end", end)
}
if tags != "" {
q.Add("tags", tags)
}
u.RawQuery = q.Encode()
res, err := c.Get(u.String())
if err != nil {
return err
}
defer func() {
res.Body.Close()
}()
body, err := io.ReadAll(res.Body)
if err != nil {
return err
}
logEntries := make([]entry.LogEntry, 0)
err = json.Unmarshal(body, &logEntries)
if err != nil {
return err
}
return logEntries
}
func (s *searchMenu) loadEntries(entries []entry.LogEntry) tea.Cmd {
items := make([]list.Item, 0, len(entries))
for _, entry := range entries {
items = append(items, item{entry})
}
return s.list.SetItems(items)
}
func (s searchMenu) View() string {
if s.showResult {
return s.resultView()
} else {
return s.menuView()
}
}
func (s searchMenu) resultView() string {
return docStyle.Render(s.list.View())
}
func (s searchMenu) menuView() string {
var b strings.Builder
for i := range s.inputs {
b.WriteString(s.inputs[i].View())
if i < len(s.inputs)-1 {
b.WriteRune('\n')
}
}
buttonStyle := &blurredStyle
if s.focusIndex == len(s.inputs) {
buttonStyle = &focusedStyle
}
fmt.Fprintf(&b, "\n\n%s\n\n", buttonStyle.Render(submitButtonText))
return b.String()
}

20
go.mod
View File

@ -1,11 +1,8 @@
module github.com/codemonkeysoftware/mouseion
module git.codemonkeysoftware.net/mouseion/server
require (
github.com/CloudyKit/jet/v6 v6.1.0
github.com/JeremyLoy/config v1.4.0
github.com/charmbracelet/bubbles v0.9.0
github.com/charmbracelet/bubbletea v0.19.1
github.com/charmbracelet/lipgloss v0.4.0
github.com/go-chi/chi/v5 v5.0.5
github.com/golang-migrate/migrate/v4 v4.14.0
github.com/gorilla/sessions v1.2.1
@ -13,32 +10,19 @@ require (
github.com/mattn/go-sqlite3 v1.14.8
github.com/volatiletech/authboss-clientstate v0.0.0-20200826024349-8d4e74078241
github.com/volatiletech/authboss/v3 v3.2.0
golang.org/x/net v0.0.0-20201029221708-28c70e62bb1d
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
)
require (
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect
github.com/atotto/clipboard v0.1.2 // indirect
github.com/containerd/console v1.0.2 // indirect
github.com/friendsofgo/errors v0.9.2 // indirect
github.com/golang/protobuf v1.4.3 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.1.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.13 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.9.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/sahilm/fuzzy v0.1.0 // indirect
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899
golang.org/x/net v0.0.0-20201029221708-28c70e62bb1d // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
golang.org/x/term v0.0.0-20210422114643-f5beecf764ed // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.25.0 // indirect

47
go.sum
View File

@ -45,8 +45,6 @@ github.com/JeremyLoy/config v1.4.0 h1:xIujFcdcIl2lDC52RLzucFXokCroAhM6HY9dui+/p2
github.com/JeremyLoy/config v1.4.0/go.mod h1:Q89XwS4S1w+hjmGVcWwb6yZjNWH3QfussGr/+y0u6Fg=
github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw=
github.com/apache/arrow/go/arrow v0.0.0-20200601151325-b2287a20f230/go.mod h1:QNYViu/X0HXDHw7m3KXzWSVXIbfUvJqBFe6Gj8/pYA0=
github.com/atotto/clipboard v0.1.2 h1:YZCtFu5Ie8qX2VmVTBnrqLSiU9XOWwqNRmdT3gIQzbY=
github.com/atotto/clipboard v0.1.2/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/aws/aws-sdk-go v1.17.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k=
github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4=
@ -54,15 +52,6 @@ github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dR
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/cenkalti/backoff/v4 v4.0.2/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/charmbracelet/bubbles v0.9.0 h1:lqJ8FXwoLceQF2J0A+dWo1Cuu1dNyjbW4Opgdi2vkhw=
github.com/charmbracelet/bubbles v0.9.0/go.mod h1:NWT/c+0rYEnYChz5qCyX4Lj6fDw9gGToh9EFJPajghU=
github.com/charmbracelet/bubbletea v0.14.1/go.mod h1:b5lOf5mLjMg1tRn1HVla54guZB+jvsyV0yYAQja95zE=
github.com/charmbracelet/bubbletea v0.19.1 h1:VHuzkJbnTAkxhOfi9+Lb5PYfNM9+Oh+qhP8uDX5ReOU=
github.com/charmbracelet/bubbletea v0.19.1/go.mod h1:VuXF2pToRxDUHcBUcPmCRUHRvFATM4Ckb/ql1rBl3KA=
github.com/charmbracelet/harmonica v0.1.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao=
github.com/charmbracelet/lipgloss v0.3.0/go.mod h1:VkhdBS2eNAmRkTwRKLJCFhCOVkjntMusBDxv7TXahuk=
github.com/charmbracelet/lipgloss v0.4.0 h1:768h64EFkGUr8V5yAKV7/Ta0NiVceiPaV+PphaW1K9g=
github.com/charmbracelet/lipgloss v0.4.0/go.mod h1:vmdkHvce7UzX6xkyf4cca8WlwdQ5RQr8fzta+xl7BOM=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
@ -71,9 +60,6 @@ github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/cockroachdb/cockroach-go v0.0.0-20190925194419-606b3d062051/go.mod h1:XGLbWH/ujMcbPbhZq52Nv6UrCghb1yGn//133kEsvDk=
github.com/containerd/console v1.0.1/go.mod h1:XUsP6YE/mKtz6bxc+I8UiKKTP04qjQL4qcS3XoQ5xkw=
github.com/containerd/console v1.0.2 h1:Pi6D+aZXM+oUw1czuKgH5IJ+y0jhYcwBJfx5/Ghn9dE=
github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8acV1PGKCbzQ=
github.com/containerd/containerd v1.4.0/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/containerd v1.4.1/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
@ -232,28 +218,17 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/ktrysmt/go-bitbucket v0.6.4/go.mod h1:9u0v3hsd2rqCHRIpbir1oP7F58uo5dq19sBYvuMoyQ4=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.8.0 h1:9xohqzkUwzR4Ga4ivdTcawVS89YSDVxXMa3xJX3cGzg=
github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/markbates/pkger v0.15.1/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
@ -261,14 +236,6 @@ github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxz
github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b h1:1XF24mVaiu7u+CFywTdcDo2ie1pzzhwjt6RHqzpMU34=
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho=
github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68/go.mod h1:Xk+z4oIWdQqJzsxyjgl3P22oYZnHdZ8FFTHAQQt5BMQ=
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
github.com/muesli/termenv v0.8.1/go.mod h1:kzt/D/4a88RoheZmwfqorY3A+tnsSMA9HJC/fQSFKo0=
github.com/muesli/termenv v0.9.0 h1:wnbOaGz+LUR3jNT0zOzinPnyDaCZUQRZj9GxK8eRVl8=
github.com/muesli/termenv v0.9.0/go.mod h1:R/LzAKf+suGs4IsO95y7+7DpFHO0KABgnZqtlyx2mBw=
github.com/mutecomm/go-sqlcipher/v4 v4.4.0/go.mod h1:PyN04SaWalavxRGH9E8ZftG6Ju7rsPrGmQRjrEaVpiY=
github.com/nakagami/firebirdsql v0.0.0-20190310045651-3c02a58cfed8/go.mod h1:86wM1zFnC6/uDBfZGNwB65O+pR2OFi5q/YQaEUid1qA=
github.com/neo4j/neo4j-go-driver v1.8.1-0.20200803113522-b626aa943eba/go.mod h1:ncO5VaFWh0Nrt+4KT4mOZboaczBZcLuHrG+/sUeP8gI=
@ -281,22 +248,16 @@ github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zM
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
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/pquerna/otp v1.2.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
github.com/sahilm/fuzzy v0.1.0 h1:FzWGaw2Opqyu+794ZQ9SYifWv2EIXpwP4q8dY1kDAwI=
github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
@ -453,7 +414,6 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -467,15 +427,8 @@ golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201029080932-201ba4db2418/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20210422114643-f5beecf764ed h1:Ei4bQjjpYUsS4efOUz+5Nz++IVkHk87n2zBA0NxBWc0=
golang.org/x/term v0.0.0-20210422114643-f5beecf764ed/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View File

@ -7,14 +7,14 @@ import (
"log"
"os"
"github.com/codemonkeysoftware/mouseion/pkg/authentication"
entrystore "github.com/codemonkeysoftware/mouseion/pkg/entry/sql_store"
"git.codemonkeysoftware.net/mouseion/server/pkg/authentication"
entrystore "git.codemonkeysoftware.net/mouseion/server/pkg/entry/sql_store"
"github.com/volatiletech/authboss/v3"
"github.com/codemonkeysoftware/mouseion/pkg/authentication/api_token"
authstore "github.com/codemonkeysoftware/mouseion/pkg/authentication/sql_store"
"github.com/codemonkeysoftware/mouseion/pkg/sqlite"
"github.com/codemonkeysoftware/mouseion/pkg/webserver"
"git.codemonkeysoftware.net/mouseion/server/pkg/authentication/api_token"
authstore "git.codemonkeysoftware.net/mouseion/server/pkg/authentication/sql_store"
"git.codemonkeysoftware.net/mouseion/server/pkg/sqlite"
"git.codemonkeysoftware.net/mouseion/server/pkg/webserver"
"github.com/JeremyLoy/config"
)

View File

@ -7,7 +7,7 @@ import (
"net/http"
"time"
"github.com/codemonkeysoftware/mouseion/pkg/views"
"git.codemonkeysoftware.net/mouseion/server/pkg/views"
"github.com/gorilla/sessions"
abclientstate "github.com/volatiletech/authboss-clientstate"
@ -20,7 +20,7 @@ import (
// authboss modules
_ "github.com/volatiletech/authboss/v3/auth"
//_ "github.com/volatiletech/authboss/v3/confirm"
_ "github.com/codemonkeysoftware/mouseion/pkg/authentication/api_token"
_ "git.codemonkeysoftware.net/mouseion/server/pkg/authentication/api_token"
_ "github.com/volatiletech/authboss/v3/logout"
_ "github.com/volatiletech/authboss/v3/register"
)

View File

@ -4,7 +4,7 @@ import (
"errors"
"testing"
"github.com/codemonkeysoftware/mouseion/pkg/authentication"
"git.codemonkeysoftware.net/mouseion/server/pkg/authentication"
"gopkg.in/gomail.v2"
)

View File

@ -4,7 +4,7 @@ import (
"bytes"
"context"
"github.com/codemonkeysoftware/mouseion/pkg/views"
"git.codemonkeysoftware.net/mouseion/server/pkg/views"
"github.com/volatiletech/authboss/v3"
)

View File

@ -6,7 +6,7 @@ import (
"errors"
"fmt"
"github.com/codemonkeysoftware/mouseion/pkg/authentication"
"git.codemonkeysoftware.net/mouseion/server/pkg/authentication"
"github.com/jmoiron/sqlx"
"github.com/mattn/go-sqlite3"
"github.com/volatiletech/authboss/v3"

View File

@ -6,8 +6,8 @@ import (
"fmt"
"time"
"github.com/codemonkeysoftware/mouseion/pkg/authentication"
"github.com/codemonkeysoftware/mouseion/pkg/authentication/api_token"
"git.codemonkeysoftware.net/mouseion/server/pkg/authentication"
"git.codemonkeysoftware.net/mouseion/server/pkg/authentication/api_token"
)
func (store *SQLStore) SaveToken(ctx context.Context, token api_token.Token) error {

View File

@ -5,7 +5,7 @@ import (
"fmt"
"time"
"github.com/codemonkeysoftware/mouseion/pkg/entry"
"git.codemonkeysoftware.net/mouseion/server/pkg/entry"
"github.com/jmoiron/sqlx"
)

View File

@ -9,10 +9,10 @@ import (
"testing"
"time"
"github.com/codemonkeysoftware/mouseion/pkg/entry"
sqlstore "github.com/codemonkeysoftware/mouseion/pkg/entry/sql_store"
"github.com/codemonkeysoftware/mouseion/pkg/sqlite"
"github.com/codemonkeysoftware/mouseion/pkg/testhelpers"
"git.codemonkeysoftware.net/mouseion/server/pkg/entry"
sqlstore "git.codemonkeysoftware.net/mouseion/server/pkg/entry/sql_store"
"git.codemonkeysoftware.net/mouseion/server/pkg/sqlite"
"git.codemonkeysoftware.net/mouseion/server/pkg/testhelpers"
)
func TestEntryLifecycle(t *testing.T) {

View File

@ -4,8 +4,8 @@ import (
"context"
"time"
"github.com/codemonkeysoftware/mouseion/pkg/authentication"
"github.com/codemonkeysoftware/mouseion/pkg/entry"
"git.codemonkeysoftware.net/mouseion/server/pkg/authentication"
"git.codemonkeysoftware.net/mouseion/server/pkg/entry"
"github.com/volatiletech/authboss/v3"
)

View File

@ -8,7 +8,7 @@ import (
"strings"
"time"
"github.com/codemonkeysoftware/mouseion/pkg/entry"
"git.codemonkeysoftware.net/mouseion/server/pkg/entry"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"

View File

@ -1,63 +0,0 @@
package source
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"time"
"github.com/codemonkeysoftware/mouseion/pkg/entry"
)
// Logger sends log messages to MouseionHost using HTTPClient. MouseionHost
// is the only required field.
type Logger struct {
HTTPClient *http.Client
LogErrors bool
MouseionHost string
}
func (logger *Logger) Print(v ...interface{}) {
logger.send(fmt.Sprint(v...))
}
func (logger *Logger) Printf(format string, v ...interface{}) {
logger.send(fmt.Sprintf(format, v...))
}
func (logger *Logger) Println(v ...interface{}) {
logger.Print(v...)
}
func (logger *Logger) send(text string) {
err := send(logger.HTTPClient, logger.MouseionHost, text)
if err != nil && logger.LogErrors {
log.Println(err)
}
}
func send(client *http.Client, host string, text string) error {
if client != nil {
client = http.DefaultClient
}
entry := entry.LogEntry{Timestamp: time.Now(), Text: text, Tags: nil}
entryJSON, err := json.Marshal(entry)
if err != nil {
return err
}
resp, err := client.Post(jsonURL(host), "application/json", bytes.NewBuffer(entryJSON))
if err != nil {
return err
}
if resp.StatusCode != http.StatusOK {
body, _ := ioutil.ReadAll(resp.Body)
return fmt.Errorf("%d %s", resp.StatusCode, body)
}
return nil
}
func jsonURL(host string) string {
return host + "/ingest.json"
}

View File

@ -1,17 +0,0 @@
package source_test
import (
"net/http"
"testing"
"github.com/codemonkeysoftware/mouseion/source"
)
func TestSendData(t *testing.T) {
logger := source.Logger{
MouseionHost: "http://localhost:8069",
HTTPClient: &http.Client{},
LogErrors: true,
}
logger.Print("hello")
}