refactor(middlewares,router): follow http package structure and interfaces

This commit is contained in:
Gustavo "Guz" L. de Mello
2024-07-22 11:24:14 -03:00
parent 294b943353
commit 9dd4681857
9 changed files with 182 additions and 117 deletions

52
routes/index.templ Normal file
View File

@@ -0,0 +1,52 @@
package routes
import (
"extrovert/templates/layouts"
"extrovert/components"
"net/http"
)
type Homepage struct{}
func (h Homepage) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_ = h.page().Render(context.Background(), w)
}
templ (h Homepage) page() {
@layouts.Page("Project Extrovert") {
<div style="max-width:50rem;">
<div style="display:flex;flex-direction:column;gap:1rem;">
<main
style="height:15rem"
>
<aside
style="height:100%;display:flex;gap:2rem;"
>
<div style="display:flex;flex-direction:column;gap:1rem;width:15rem;">
@components.LoginTwitter()
@components.LoginMastodon()
</div>
<fieldset>
<textarea
style="height:100%;resize:none;"
name="post"
placeholder="Write a post..."
aria-label="Post input"
></textarea>
</fieldset>
</aside>
</main>
<footer>
@components.Warning("In Development") {
<strong>
This application is in active development and should not be used in production.
</strong>
Expect bugs, lost data, logouts, etc. Use it at your own risk.
This software is provided "as is", without any warranty of any kind.
}
</footer>
</div>
</div>
}
}