feat: gpg and ssh keys

This commit is contained in:
ange 2024-12-10 18:30:56 +00:00
parent f08dfa02ab
commit b9d7553420
Signed by: ange
GPG key ID: 9E0C4157BB7BEB1D
6 changed files with 45 additions and 18 deletions

View file

@ -5,8 +5,6 @@ import (
"net/http"
)
// TODO: html templates
// TODO: download resume as PDF
func main() {
http.HandleFunc("/", Route)

View file

@ -4,33 +4,21 @@ import (
"context"
"fmt"
"net/http"
"path/filepath"
"regexp"
"slices"
)
type URLParam struct{}
type W = http.ResponseWriter
type R = *http.Request
var routes = []struct {
methods []string
regex *regexp.Regexp
handler http.HandlerFunc
}{
{[]string{"GET"}, URL(""), func(w W, r R) {
http.ServeFile(w, r, filepath.Join("html", "index.html"))
}},
{[]string{"GET"}, URL("/style\\.css"), func(w W, r R) {
http.ServeFile(w, r, "/html/style.css")
}},
{[]string{"GET"}, URL("/static/.+"), func(w W, r R) {
http.ServeFile(w, r, r.URL.Path)
}},
{[]string{"GET"}, URL("/[^/]+"), func(w W, r R) {
http.ServeFile(w, r, filepath.Join("html", r.URL.Path + ".html"))
}},
{[]string{"GET"}, URL(""), Index},
{[]string{"GET"}, URL("/style\\.css"), Style},
{[]string{"GET"}, URL("/static/.+"), Static},
{[]string{"GET"}, URL("/[^/]+"), HTML},
}
func URL(s string) *regexp.Regexp {

22
src/views.go Normal file
View file

@ -0,0 +1,22 @@
package main
import (
"net/http"
"path/filepath"
)
func Index(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, filepath.Join("html", "index.html"))
}
func Style(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "/html/style.css")
}
func Static(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, r.URL.Path)
}
func HTML(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, filepath.Join("html", r.URL.Path + ".html"))
}