test
This commit is contained in:
parent
4b0f051603
commit
a3274355bc
@ -1,24 +0,0 @@
|
|||||||
package handlers
|
|
||||||
|
|
||||||
import (
|
|
||||||
"html/template"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
func InitAboutpage(w http.ResponseWriter, r *http.Request) {
|
|
||||||
|
|
||||||
tmpl := template.Must(template.ParseFiles(
|
|
||||||
"./templates/about/index.html",
|
|
||||||
"./templates/navbar/index.html",
|
|
||||||
"./templates/themeSelector/index.html",
|
|
||||||
))
|
|
||||||
|
|
||||||
err := tmpl.Execute(w, nil)
|
|
||||||
if err != nil {
|
|
||||||
_, err := w.Write([]byte("failed to load"))
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
package handlers
|
|
||||||
|
|
||||||
import (
|
|
||||||
"html/template"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
func InitHomepage(w http.ResponseWriter, r *http.Request) {
|
|
||||||
|
|
||||||
tmpl := template.Must(template.ParseFiles(
|
|
||||||
"./templates/homepage/index.html",
|
|
||||||
"./templates/navbar/index.html",
|
|
||||||
"./templates/themeSelector/index.html",
|
|
||||||
))
|
|
||||||
|
|
||||||
err := tmpl.Execute(w, nil)
|
|
||||||
if err != nil {
|
|
||||||
_, err := w.Write([]byte("failed to load"))
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func UpdateTheme(w http.ResponseWriter, r *http.Request) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test(w http.ResponseWriter, r *http.Request) {
|
|
||||||
|
|
||||||
tmpl := template.Must(template.ParseFiles(
|
|
||||||
"./templates/homepage/index.html",
|
|
||||||
"./templates/navbar/index.html",
|
|
||||||
"./templates/themeSelector/index.html",
|
|
||||||
))
|
|
||||||
|
|
||||||
err := tmpl.Execute(w, nil)
|
|
||||||
if err != nil {
|
|
||||||
_, err := w.Write([]byte("failed to load"))
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
package handlers
|
|
||||||
|
|
||||||
import (
|
|
||||||
"html/template"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
func InitLoginpage(w http.ResponseWriter, r *http.Request) {
|
|
||||||
|
|
||||||
tmpl := template.Must(template.ParseFiles(
|
|
||||||
"./templates/login/index.html",
|
|
||||||
"./templates/navbar/index.html",
|
|
||||||
"./templates/themeSelector/index.html",
|
|
||||||
))
|
|
||||||
|
|
||||||
err := tmpl.Execute(w, nil)
|
|
||||||
if err != nil {
|
|
||||||
_, err := w.Write([]byte("failed to load"))
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
package handlers
|
|
||||||
|
|
||||||
import (
|
|
||||||
"html/template"
|
|
||||||
"net/http"
|
|
||||||
"portfolio/api/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
func InitProjectpage(w http.ResponseWriter, r *http.Request) {
|
|
||||||
|
|
||||||
tmpl := template.Must(template.ParseFiles("./templates/index.html"))
|
|
||||||
|
|
||||||
userNames := map[string][]types.Username{
|
|
||||||
"Names": {
|
|
||||||
{Name: "The Godfather"},
|
|
||||||
{Name: "Blade Runner"},
|
|
||||||
{Name: "The Thing"},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
err := tmpl.Execute(w, userNames)
|
|
||||||
if err != nil {
|
|
||||||
_, err := w.Write([]byte("failed to load"))
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -2,7 +2,7 @@ package web
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"portfolio/web/handlers"
|
handlers2 "portfolio/api/handlers"
|
||||||
)
|
)
|
||||||
|
|
||||||
func WebRoutes() *http.ServeMux {
|
func WebRoutes() *http.ServeMux {
|
||||||
@ -11,14 +11,7 @@ func WebRoutes() *http.ServeMux {
|
|||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
|
|
||||||
// Register the routes and webHandler
|
// Register the routes and webHandler
|
||||||
mux.HandleFunc("GET /{$}", handlers.InitHomepage)
|
mux.HandleFunc("/", handlers2.CatchAllHandler)
|
||||||
mux.HandleFunc("GET /projecten/{$}", handlers.InitProjectpage)
|
|
||||||
mux.HandleFunc("GET /about/{$}", handlers.InitAboutpage)
|
|
||||||
mux.HandleFunc("GET /login/{$}", handlers.InitLoginpage)
|
|
||||||
|
|
||||||
mux.HandleFunc("POST /theme", handlers.UpdateTheme)
|
|
||||||
|
|
||||||
mux.HandleFunc("GET /test", handlers.Test)
|
|
||||||
|
|
||||||
return mux
|
return mux
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user