You've already forked hastebin-ansi
mirror of
https://github.com/armbian/hastebin-ansi.git
synced 2026-01-06 12:30:55 -08:00
improve project structure
This commit is contained in:
@@ -7,8 +7,8 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/armbian/ansi-hastebin/keygenerator"
|
||||
"github.com/armbian/ansi-hastebin/storage"
|
||||
"github.com/armbian/ansi-hastebin/internal/keygenerator"
|
||||
"github.com/armbian/ansi-hastebin/internal/storage"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@@ -22,7 +22,6 @@ type DocumentHandler struct {
|
||||
}
|
||||
|
||||
func NewDocumentHandler(keyLength, maxLength int, store storage.Storage, keyGenerator keygenerator.KeyGenerator) *DocumentHandler {
|
||||
keyLength = 10
|
||||
return &DocumentHandler{
|
||||
KeyLength: keyLength,
|
||||
MaxLength: maxLength,
|
||||
@@ -31,6 +30,20 @@ func NewDocumentHandler(keyLength, maxLength int, store storage.Storage, keyGene
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterRoutes registers document routes
|
||||
func (h *DocumentHandler) RegisterRoutes(r chi.Router) {
|
||||
r.Get("/raw/{id}", h.HandleRawGet)
|
||||
r.Head("/raw/{id}", h.HandleRawGet)
|
||||
|
||||
r.Post("/log", h.HandlePutLog)
|
||||
r.Put("/log", h.HandlePutLog)
|
||||
|
||||
r.Post("/documents", h.HandlePost)
|
||||
|
||||
r.Get("/documents/{id}", h.HandleGet)
|
||||
r.Head("/documents/{id}", h.HandleGet)
|
||||
}
|
||||
|
||||
// Handle retrieving a document
|
||||
func (h *DocumentHandler) HandleGet(w http.ResponseWriter, r *http.Request) {
|
||||
key := strings.Split(chi.URLParam(r, "id"), ".")[0]
|
||||
|
||||
Reference in New Issue
Block a user