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: 0

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

Jump to

Keyboard shortcuts

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