dizxo

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: MIT Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

disxo-web-api

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NopHandler http.HandlerFunc = func(w http.ResponseWriter, r *http.Request) {

}

Functions

func AuthHandler

func AuthHandler(auth *Auth) http.HandlerFunc

func CORS

func CORS(cfg *Config) func(handler http.Handler) http.Handler

func CloseDB

func CloseDB(db *sql.DB)

func ConnectDB

func ConnectDB(cfg *Config) error

func Fatal added in v0.3.0

func Fatal(err error)

func GetDB

func GetDB() *sql.DB

func GetFatal added in v0.3.0

func GetFatal[V any](value V, err error) V

func MeHandler

func MeHandler(auth *Auth) http.HandlerFunc

Types

type Auth

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

func NewAuth

func NewAuth() Auth

func (*Auth) Authorize

func (a *Auth) Authorize(email string, password string) (*Session, error)

func (*Auth) Find

func (a *Auth) Find(cookie string) (*Session, bool)

func (*Auth) Save added in v0.3.0

func (a *Auth) Save(email string, password string) error

type Config

type Config struct {
	Port       string
	DBUrl      string
	CORSOrigin string
}

func NewConfig

func NewConfig() (*Config, error)

type Session

type Session struct {
	Email     string
	Cookie    string
	ExpiresAt time.Time
}

Directories

Path Synopsis
cmd
dizxo command
migrate command
user command

Jump to

Keyboard shortcuts

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