43 lines
803 B
Go
43 lines
803 B
Go
package sriracha
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
func handleRequest(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
|
fmt.Fprintf(w, "<h1>Testing</h1>")
|
|
|
|
reader := bytes.NewReader([]byte("Test"))
|
|
a, err := attach(reader, 4, "image/png")
|
|
log.Println(a, "-", err)
|
|
|
|
p := &Post{
|
|
ID: 1,
|
|
Thread: 0,
|
|
Email: "test@mail.com",
|
|
Name: "Anonymous",
|
|
Subject: "Sub",
|
|
Message: "Msg",
|
|
}
|
|
err = post(p)
|
|
log.Println("post err", err)
|
|
|
|
err = p.render(w)
|
|
if err != nil {
|
|
log.Fatal("render post err", err)
|
|
}
|
|
}
|
|
|
|
func Run(driver string, dataSource string) error {
|
|
err := connectDB(driver, dataSource)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
http.HandleFunc("/imgboard", handleRequest)
|
|
return http.ListenAndServe(":8080", nil)
|
|
}
|