no longer pass base64 encoding to handlers
This commit is contained in:
parent
9f1c4dd9e6
commit
08fbba0e0a
3 changed files with 4 additions and 7 deletions
5
main.go
5
main.go
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"embed"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"log"
|
||||
"net/http"
|
||||
|
@ -37,12 +36,12 @@ func run() error {
|
|||
mux.Handle(
|
||||
"POST /api/password",
|
||||
middlewares.RateLimiter(
|
||||
routes.CreatePassword(storage, maxPasswordLength, base64.StdEncoding),
|
||||
routes.CreatePassword(storage, maxPasswordLength),
|
||||
1*time.Minute,
|
||||
5,
|
||||
),
|
||||
)
|
||||
mux.Handle("GET /api/password/{id}", routes.GetPassword(storage, base64.StdEncoding))
|
||||
mux.Handle("GET /api/password/{id}", routes.GetPassword(storage))
|
||||
mux.Handle("HEAD /api/password/{id}", routes.HasPassword(storage))
|
||||
|
||||
if logRequests {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package routes
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"time"
|
||||
|
@ -9,7 +8,7 @@ import (
|
|||
"git.1e99.eu/1e99/passed/storage"
|
||||
)
|
||||
|
||||
func CreatePassword(store storage.Store, maxLength int, encoding *base64.Encoding) http.HandlerFunc {
|
||||
func CreatePassword(store storage.Store, maxLength int) http.HandlerFunc {
|
||||
return func(res http.ResponseWriter, req *http.Request) {
|
||||
var reqBody struct {
|
||||
// Go automatically decodes byte arrays using Base64
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package routes
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"git.1e99.eu/1e99/passed/storage"
|
||||
)
|
||||
|
||||
func GetPassword(store storage.Store, encoding *base64.Encoding) http.HandlerFunc {
|
||||
func GetPassword(store storage.Store) http.HandlerFunc {
|
||||
return func(res http.ResponseWriter, req *http.Request) {
|
||||
id := req.PathValue("id")
|
||||
password, err := store.Get(id)
|
||||
|
|
Loading…
Reference in a new issue