55 lines
898 B
Go
55 lines
898 B
Go
package server
|
|
|
|
import (
|
|
"fmt"
|
|
"local/notes-server/config"
|
|
"local/router"
|
|
"net/http"
|
|
)
|
|
|
|
type Server struct {
|
|
*router.Router
|
|
}
|
|
|
|
func New() *Server {
|
|
return &Server{
|
|
Router: router.New(),
|
|
}
|
|
}
|
|
|
|
func head(w http.ResponseWriter, r *http.Request) {
|
|
w.Write([]byte(config.Head + "\n"))
|
|
}
|
|
|
|
func foot(w http.ResponseWriter, r *http.Request) {
|
|
w.Write([]byte(config.Foot + "\n"))
|
|
}
|
|
|
|
func block(content string, w http.ResponseWriter) {
|
|
fmt.Fprintf(w, "\n<div>\n%s\n</div>\n", content)
|
|
}
|
|
|
|
func h1(content string) string {
|
|
return h("1", content)
|
|
}
|
|
|
|
func h2(content string) string {
|
|
return h("2", content)
|
|
}
|
|
|
|
func h3(content string) string {
|
|
return h("3", content)
|
|
}
|
|
|
|
func h4(content string) string {
|
|
return h("4", content)
|
|
}
|
|
|
|
func h5(content string) string {
|
|
return h("5", content)
|
|
}
|
|
|
|
func h(level, content string) string {
|
|
return fmt.Sprintf("\n<h%s>\n%s\n</h%s>\n", level, content, level)
|
|
}
|