service

package module
v0.0.0-...-816ca63 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IsLetter = regexp.MustCompile(`^[0-9a-zA-Z_\-]+$`).MatchString

Functions

func Init

func Init(mux *http.ServeMux, config Config)

func Parse

func Parse[T any](r *http.Request, v T) (err error)

func UserFrom

func UserFrom(r *http.Request) (uid uint64, err error)

func ValidShort

func ValidShort(short string) (ok bool)

func ValidUrl

func ValidUrl(url string) (err error)

Types

type AuthConfig

type AuthConfig struct {
	ClientID     string
	ClientSecret string
	Key          []byte
	JWTKey       []byte
	JWTTimeout   time.Duration
	Issuer       string
	Scopes       []string
	BaseURL      string
	CallbackURL  string
	LoginURL     string
	Logger       *slog.Logger
}

type Config

type Config struct {
	AuthConfig
	ShortURLPrefix string
	DB             db.Interface
	CacheTTL       time.Duration
	CacheSize      int
}

type CreateRequest

type CreateRequest struct {
	Short string `json:"Short"`
	Long  string `json:"Long"`
}

type CreateResponse

type CreateResponse struct {
}

type DeleteRequest

type DeleteRequest struct {
	Short string `json:"Short"`
}

type DeleteResponse

type DeleteResponse struct {
}

type ListEntry

type ListEntry struct {
	Short string `json:"Short"`
	Long  string `json:"Long"`
	Hits  int    `json:"Hits"`
}

type LogEntry

type LogEntry struct {
	Host      string    `json:"Host"`
	Timestamp time.Time `json:"Timestamp"`
}

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

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