arimelody.me/api/v1/admin/admin.go
ari melody c5a2491627 the shrimplest admin api you've ever seen
Signed-off-by: ari melody <ari@arimelody.me>
2024-08-31 01:52:30 +01:00

44 lines
821 B
Go

package admin
import (
"fmt"
"html/template"
"io"
"net/http"
)
type (
State struct {
Token string
}
)
func CreateState() *State {
return &State{
Token: "you are the WINRAR!!",
}
}
func HandleLogin(writer http.ResponseWriter, req *http.Request, root *template.Template) int {
if req.Method != "POST" {
return 404;
}
body, err := io.ReadAll(req.Body)
if err != nil {
fmt.Printf("failed to parse request body!\n");
return 500;
}
if string(body) != "super epic mega gaming password" {
return 400;
}
state := CreateState();
writer.WriteHeader(200);
writer.Write([]byte(state.Token))
return 200;
}