forked from mna/trofaf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
40 lines (34 loc) · 803 Bytes
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"fmt"
"log"
"net/http"
_ "net/http/pprof"
"path/filepath"
"time"
"github.com/PuerkitoBio/ghost/handlers"
)
// Start serving the blog.
func run() {
var (
faviconPath = filepath.Join(PublicDir, "favicon.ico")
faviconCache = 2 * 24 * time.Hour
)
h := handlers.FaviconHandler(
handlers.PanicHandler(
handlers.LogHandler(
handlers.GZIPHandler(
http.FileServer(http.Dir(PublicDir)),
nil),
handlers.NewLogOptions(nil, handlers.Ldefault)),
nil),
faviconPath,
faviconCache)
// Assign the combined handler to the server.
http.Handle("/", h)
// Start it up.
log.Printf("trofaf server listening on port %d", Options.Port)
if err := http.ListenAndServe(fmt.Sprintf(":%d", Options.Port), nil); err != nil {
log.Fatal("FATAL ", err)
}
}