Fix, placeholder image, api

Added a placeholder image, code style
Fixed metadata missing issue
More work on api
This commit is contained in:
Melody Becker 2024-11-06 16:58:57 +01:00
parent 529d106351
commit 0e036b152b
8 changed files with 192 additions and 94 deletions

View file

@ -1,6 +1,7 @@
package server
import (
"fmt"
"io/fs"
"net/http"
@ -15,8 +16,13 @@ type Server struct {
router http.Handler
}
func NewServer(store *storage.Storage, pkey *passkey.Passkey, reactiveFS, staticFS fs.FS) *Server {
handler := buildRootHandler(pkey, reactiveFS, staticFS)
func NewServer(
store *storage.Storage,
pkey *passkey.Passkey,
reactiveFS, staticFS fs.FS,
placeholderFile *string,
) *Server {
handler := buildRootHandler(pkey, reactiveFS, staticFS, placeholderFile)
handler = ChainMiddlewares(handler, LoggingMiddleware, ContextValsMiddleware(map[any]any{
ContextKeyStorage: store,
}))
@ -26,7 +32,11 @@ func NewServer(store *storage.Storage, pkey *passkey.Passkey, reactiveFS, static
}
}
func buildRootHandler(pkey *passkey.Passkey, reactiveFS, staticFS fs.FS) http.Handler {
func buildRootHandler(
pkey *passkey.Passkey,
reactiveFS, staticFS fs.FS,
placeholderFile *string,
) http.Handler {
mux := http.NewServeMux()
mux.Handle(
"/webauthn/",
@ -61,6 +71,10 @@ func buildRootHandler(pkey *passkey.Passkey, reactiveFS, staticFS fs.FS) http.Ha
)(ChainMiddlewares(setupTestEndpoints(), passkeyIdToAccountIdTransformerMiddleware)),
)
mux.HandleFunc("/placeholder-file", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, placeholderFile)
})
return mux
}