init llm generated microblog submodule
This commit is contained in:
parent
1c7341499a
commit
216ace7afa
5 changed files with 241 additions and 1 deletions
14
main.go
14
main.go
|
|
@ -10,16 +10,26 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"gemini_site/internal/microblog"
|
||||
|
||||
gemini "github.com/kulak/gemini"
|
||||
)
|
||||
|
||||
type ExampleHandler struct {
|
||||
blog microblog.Handler
|
||||
}
|
||||
|
||||
func (h ExampleHandler) ServeGemini(w gemini.ResponseWriter, req *gemini.Request) {
|
||||
slog.Info("gemini request",
|
||||
"path", req.URL.Path,
|
||||
"user", strings.Join(userName(req), " "))
|
||||
|
||||
// Check if this is a blog request
|
||||
if strings.HasPrefix(req.URL.Path, "/blog") {
|
||||
h.blog.HandleBlogRequest(w, req)
|
||||
return
|
||||
}
|
||||
|
||||
switch req.URL.Path {
|
||||
case "/":
|
||||
gemini.ServeFileName("pages/home.gmi", "text/gemini")(w, req)
|
||||
|
|
@ -92,7 +102,9 @@ func main() {
|
|||
flag.StringVar(&key, "key", "server.key.pem", "private key associated with certificate file")
|
||||
flag.Parse()
|
||||
|
||||
handler := ExampleHandler{}
|
||||
handler := ExampleHandler{
|
||||
blog: microblog.NewHandler(),
|
||||
}
|
||||
|
||||
err := gemini.ListenAndServe(host, cert, key, gemini.TrapPanic(handler.ServeGemini))
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue