...

Source file src/code.rocketnine.space/tslocum/sriracha/server.go

Documentation: code.rocketnine.space/tslocum/sriracha

     1  package sriracha
     2  
     3  import (
     4  	"bytes"
     5  	"fmt"
     6  	"log"
     7  	"net/http"
     8  )
     9  
    10  func handleRequest(w http.ResponseWriter, r *http.Request) {
    11  	w.Header().Set("Content-Type", "text/html; charset=utf-8")
    12  	fmt.Fprintf(w, "<h1>Testing</h1>")
    13  
    14  	reader := bytes.NewReader([]byte("Test"))
    15  	a, err := attach(reader, 4, "image/png")
    16  	log.Println(a, "-", err)
    17  
    18  	p := &Post{
    19  		ID:      1,
    20  		Thread:  0,
    21  		Email:   "test@mail.com",
    22  		Name:    "Anonymous",
    23  		Subject: "Sub",
    24  		Message: "Msg",
    25  	}
    26  	err = post(p)
    27  	log.Println("post err", err)
    28  
    29  	err = p.render(w)
    30  	if err != nil {
    31  		log.Fatal("render post err", err)
    32  	}
    33  }
    34  
    35  func Run() error {
    36  	http.HandleFunc("/imgboard", handleRequest)
    37  	return http.ListenAndServe(":8080", nil)
    38  }
    39  

View as plain text