save
This commit is contained in:
35
internal/handlers/file.go
Normal file
35
internal/handlers/file.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"lash"
|
||||
"lash/internal/errx"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type FileData struct {
|
||||
Contents []byte
|
||||
}
|
||||
|
||||
type ValidateRequest struct {
|
||||
Token string
|
||||
}
|
||||
|
||||
func (h FileData) APIHandler(w http.ResponseWriter, r *http.Request) {
|
||||
decoder := json.NewDecoder(r.Body)
|
||||
var t ValidateRequest
|
||||
err := decoder.Decode(&t)
|
||||
if err != nil {
|
||||
errx.FatalPerror(err)
|
||||
}
|
||||
|
||||
if t.Token == lash.Token {
|
||||
errx.Log("Got token")
|
||||
} else {
|
||||
errx.Log("No Token")
|
||||
}
|
||||
}
|
||||
|
||||
func (h FileData) DownloadHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write(h.Contents)
|
||||
}
|
||||
Reference in New Issue
Block a user