paste

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreatePasteRequest

type CreatePasteRequest struct {
	Content   string `json:"content" validate:"required,max=1048576"` // 1MB max
	Language  string ``                                               /* 169-byte string literal not displayed */
	Encrypted bool   `json:"encrypted"`
	OneTime   bool   `json:"onetime"`
}

type Paste

type Paste struct {
	Short     string
	Content   string
	Language  string // Optional: "go", "python", "json", "markdown", etc.
	Encrypted bool
	OneTime   bool
	CreatedAt time.Time
	ExpiresAt time.Time
}

type PasteHandler

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

func NewPasteHandler

func NewPasteHandler(pasteService *PasteService) *PasteHandler

func (*PasteHandler) CreatePaste

func (h *PasteHandler) CreatePaste(w http.ResponseWriter, r *http.Request) error

CreatePaste creates a new text paste @Summary Create a paste @Description Creates a text paste (code, logs, plain text) @Tags paste @Accept json @Produce json @Param paste body CreatePasteRequest true "Paste content and options" @Success 201 {string} string "Paste URL" @Failure 400 "Invalid request" @Failure 500 "Internal server error" @Router /api/pastes [post]

func (*PasteHandler) GetPasteByShort

func (h *PasteHandler) GetPasteByShort(w http.ResponseWriter, r *http.Request) error

GetPasteByShort retrieves and serves the paste content @Summary Get paste by short code @Description Returns the paste content as text/plain (or encrypted data as JSON if encrypted) @Tags paste @Param short path string true "Short code (6 characters)" @Success 200 {string} string "Paste content" @Failure 404 @Failure 422 @Router /p/{short} [get]

type PasteRepo

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

func NewPasteRepo

func NewPasteRepo(db *badger.DB) *PasteRepo

func (*PasteRepo) Create

func (r *PasteRepo) Create(paste *Paste) error

func (*PasteRepo) Delete

func (r *PasteRepo) Delete(short string) error

func (*PasteRepo) GetByShort

func (r *PasteRepo) GetByShort(short string) (*Paste, error)

type PasteResponse

type PasteResponse struct {
	Data string `json:"data"`
}

type PasteService

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

func NewPasteService

func NewPasteService(pasteRepo *PasteRepo) *PasteService

func (*PasteService) CreatePaste

func (s *PasteService) CreatePaste(content string, language string, encrypted bool, onetime bool) (*Paste, error)

func (*PasteService) DeletePaste

func (s *PasteService) DeletePaste(short string) error

func (*PasteService) GetPaste

func (s *PasteService) GetPaste(short string) (*Paste, error)

Jump to

Keyboard shortcuts

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