all repos — flounder @ f282a3b485f2bbe813913fc8e61edc5cc6370161

A small site builder for the Gemini protocol

http.go (view raw)

 1package main
 2
 3import (
 4	"fmt"
 5	"log"
 6	"net/http"
 7)
 8
 9func indexHandler(w http.ResponseWriter, r *http.Request) {
10	indexFiles, _ := getIndexFiles()
11	for _, file := range indexFiles {
12		fmt.Fprintf(w, "%s\n", file.Name)
13	}
14}
15
16func editFileHandler(w http.ResponseWriter, r *http.Request) {
17	// get vs post
18	// read file content
19	authUser := "alex"
20	files, _ := getUserFiles(authUser)
21	for _, file := range files {
22		fmt.Fprintf(w, "%s\n", file.Name)
23	}
24}
25
26func mySiteHandler(w http.ResponseWriter, r *http.Request) {
27	authUser := "alex"
28	files, _ := getUserFiles(authUser)
29	for _, file := range files {
30		fmt.Fprintf(w, "%s\n", file.Name)
31	}
32}
33
34func runHTTPServer() {
35	http.HandleFunc("/", indexHandler)
36	http.HandleFunc("/my_site", mySiteHandler)
37	http.HandleFunc("/edit/", editFileHandler)
38	// http.HandleFunc("/delete/", deleteFileHandler)
39	// login+register functions
40	log.Fatal(http.ListenAndServe(":8080", nil))
41}