pimbin

package module
v0.0.0-...-c043382 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: ISC Imports: 30 Imported by: 0

README

pimbin

builds.sr.ht status

a (wip) file bin/host/uploader

this readme is just a placeholder, so check back later

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB is a pimbin database.

func OpenSQLiteDB

func OpenSQLiteDB(source string) (*DB, error)

OpenSQLiteDB opens and returns an sqlite3 database from the path provided.

func (*DB) Close

func (db *DB) Close() error

Close closes the DB.

func (*DB) CreateUser

func (db *DB) CreateUser(user *User) error

CreateUser inserts user into the database.

func (*DB) DeletePaste

func (db *DB) DeletePaste(id string) error

DeletePaste deletes a paste and its file entries by the id.

func (*DB) Paste

func (db *DB) Paste(id string) (*Paste, error)

Paste returns a paste from its ID.

func (*DB) PutPaste

func (db *DB) PutPaste(p Paste) error

PutPaste inserts the given paste into the database.

func (*DB) RefreshToken

func (db *DB) RefreshToken(user *User) (string, error)

RefreshToken refreshes a user's token and returns the new token.

func (*DB) UpdatePassword

func (db *DB) UpdatePassword(user *User) error

UpdatePassword records changes to user's password in the database.

func (*DB) User

func (db *DB) User(username string) (*User, error)

User returns a user from their username, or an error if one occurs while trying to retrieve them.

func (*DB) Users

func (db *DB) Users() ([]User, error)

Users lists the users in the database.

type File

type File struct {
	Hash string
	Name string
}

File describes a paste's file.

type Paste

type Paste struct {
	ID    string
	Owner string
	Files []File
}

Paste contains a paste's data.

type Server

type Server struct {
	Config config.Server
	// contains filtered or unexported fields
}

Server is a pimbin server, and contains some options.

func NewServer

func NewServer(db *DB) (*Server, error)

NewServer returns a new Server that uses the given database.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

type User

type User struct {
	Password string
	Name     string
	Token    string
}

User contains a user's data.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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