internal

package
v0.0.0-...-dee2251 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

func NewHandlerAPI

func NewHandlerAPI(store *SQLStore) *API

func (*API) GetAllDocumentHandler

func (api *API) GetAllDocumentHandler(w http.ResponseWriter, r *http.Request)

func (*API) GetOneDocumentHandler

func (api *API) GetOneDocumentHandler(w http.ResponseWriter, r *http.Request)

func (*API) GetOneUserHandler

func (api *API) GetOneUserHandler(w http.ResponseWriter, r *http.Request)

func (*API) InsertDocumentHandler

func (api *API) InsertDocumentHandler(w http.ResponseWriter, r *http.Request)

func (*API) InsertUserHandler

func (api *API) InsertUserHandler(w http.ResponseWriter, r *http.Request)

func (*API) UpdateDocumentHandler

func (api *API) UpdateDocumentHandler(w http.ResponseWriter, r *http.Request)

func (*API) UpdateUserHandler

func (api *API) UpdateUserHandler(w http.ResponseWriter, r *http.Request)

type ContextKey

type ContextKey int
const (
	KeyUsername        ContextKey = iota
	KeyIsAuthenticated ContextKey = iota
)

type Document

type Document struct {
	ID        int64     `db:"id"`
	Title     string    `db:"title"`
	Body      string    `db:"body"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

type Page

type Page struct {
	// contains filtered or unexported fields
}

func NewHandlerPage

func NewHandlerPage(store *SQLStore) *Page

func (*Page) CreateSession

func (page *Page) CreateSession(w http.ResponseWriter, r *http.Request)

func (*Page) DeleteSession

func (page *Page) DeleteSession(w http.ResponseWriter, r *http.Request)

func (*Page) RenderAllDocument

func (page *Page) RenderAllDocument(w http.ResponseWriter, r *http.Request)

func (*Page) RenderDashboard

func (page *Page) RenderDashboard(w http.ResponseWriter, r *http.Request)

func (*Page) RenderEditDocument

func (page *Page) RenderEditDocument(w http.ResponseWriter, r *http.Request)

func (*Page) RenderEditor

func (page *Page) RenderEditor(w http.ResponseWriter, r *http.Request)

func (*Page) RenderIndex

func (page *Page) RenderIndex(w http.ResponseWriter, r *http.Request)

func (*Page) RenderLogin

func (page *Page) RenderLogin(w http.ResponseWriter, r *http.Request)

func (*Page) RenderNewDocument

func (page *Page) RenderNewDocument(w http.ResponseWriter, r *http.Request)

func (*Page) RenderNewUser

func (page *Page) RenderNewUser(w http.ResponseWriter, r *http.Request)

func (*Page) RenderOneDocument

func (page *Page) RenderOneDocument(w http.ResponseWriter, r *http.Request)

func (*Page) SaveEditDocument

func (page *Page) SaveEditDocument(w http.ResponseWriter, r *http.Request)

func (*Page) SaveNewDocument

func (page *Page) SaveNewDocument(w http.ResponseWriter, r *http.Request)

func (*Page) SaveNewUser

func (page *Page) SaveNewUser(w http.ResponseWriter, r *http.Request)

type SQLStore

type SQLStore struct {
	// contains filtered or unexported fields
}

func NewSQLStore

func NewSQLStore(db *sqlx.DB) *SQLStore

func (*SQLStore) DeleteSession

func (s *SQLStore) DeleteSession(ctx context.Context, tokenHash string) error

func (*SQLStore) GetAllDocument

func (s *SQLStore) GetAllDocument(ctx context.Context) ([]*Document, error)

func (*SQLStore) GetOneDocument

func (s *SQLStore) GetOneDocument(
	ctx context.Context,
	id int64,
) (*Document, error)

func (*SQLStore) GetOneSession

func (s *SQLStore) GetOneSession(ctx context.Context, tokenHash string) (
	*Session,
	error,
)

func (*SQLStore) GetOneUser

func (s *SQLStore) GetOneUser(ctx context.Context, id int64) (*User, error)

func (*SQLStore) GetOneUserByUsername

func (s *SQLStore) GetOneUserByUsername(
	ctx context.Context,
	username string,
) (*User, error)

func (*SQLStore) GetUsernameSession

func (s *SQLStore) GetUsernameSession(
	ctx context.Context,
	tokenHash string,
) string

func (*SQLStore) InsertDocument

func (s *SQLStore) InsertDocument(
	ctx context.Context,
	d *Document,
) (int64, error)

func (*SQLStore) InsertSession

func (s *SQLStore) InsertSession(
	ctx context.Context,
	d *Session,
) (int64, error)

func (*SQLStore) InsertUser

func (s *SQLStore) InsertUser(ctx context.Context, d *User) (int64, error)

func (*SQLStore) InsertUserPage

func (s *SQLStore) InsertUserPage(
	ctx context.Context,
	username string,
	email string,
	passwordHash string,
) (int64, error)

func (*SQLStore) UpdateDocument

func (s *SQLStore) UpdateDocument(
	ctx context.Context,
	id int64,
	field string,
	value string,
) error

func (*SQLStore) UpdateUser

func (s *SQLStore) UpdateUser(
	ctx context.Context,
	id int64,
	field string,
	value string,
) error

type Session

type Session struct {
	ID        int64  `db:"id"`
	UserID    int64  `db:"user_id"`
	TokenHash string `db:"token_hash"`
}

type User

type User struct {
	ID           int64     `db:"id"`
	Username     string    `db:"username"`
	Email        string    `db:"email"`
	PasswordHash string    `db:"password_hash"`
	CreatedAt    time.Time `db:"created_at"`
	UpdatedAt    time.Time `db:"updated_at"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL