1.0 version
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"lash/internal/errx"
|
||||
"lash/internal/handlers"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func New() http.Handler {
|
||||
@@ -15,12 +16,19 @@ func New() http.Handler {
|
||||
errx.FatalPerror(err)
|
||||
}
|
||||
|
||||
share := handlers.ShareData{
|
||||
Version: lash.Version,
|
||||
FileName: fp,
|
||||
contents, err := os.ReadFile(fp)
|
||||
if err != nil {
|
||||
errx.FatalPerror(err)
|
||||
}
|
||||
|
||||
file := handlers.FileData{}
|
||||
share := handlers.ShareData{
|
||||
Version: lash.Version,
|
||||
}
|
||||
|
||||
file := handlers.FileData{
|
||||
Contents: contents,
|
||||
FileName: fp,
|
||||
}
|
||||
|
||||
mux.HandleFunc("/", share.Handler)
|
||||
mux.HandleFunc("/api/receive-token", file.APIHandler)
|
||||
|
||||
@@ -2,13 +2,15 @@ package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"lash"
|
||||
"strconv"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type FileData struct {
|
||||
Contents []byte
|
||||
FileName string
|
||||
}
|
||||
|
||||
type ValidateRequest struct {
|
||||
@@ -30,7 +32,7 @@ func (h FileData) APIHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Disposition", "attachment; filename=file.bin")
|
||||
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", h.FileName))
|
||||
w.Header().Set("Content-Type", "application/octet-stream")
|
||||
w.Header().Set("Content-Length", strconv.Itoa(len(h.Contents)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user