github.com/DamienFontaine/lunarc@v0.0.0-20190122154304-2e7332a51f55/README.md (about) 1 # Lunarc 2 3 [![Build Status](https://travis-ci.org/DamienFontaine/lunarc.svg?branch=master)](https://travis-ci.org/DamienFontaine/lunarc) 4 [![Coverage Status](https://coveralls.io/repos/github/DamienFontaine/lunarc/badge.svg?branch=master)](https://coveralls.io/github/DamienFontaine/lunarc?branch=master) 5 [![GoDoc](https://godoc.org/github.com/DamienFontaine/lunarc?status.png)](https://godoc.org/github.com/DamienFontaine/lunarc) 6 7 ## Download and install 8 9 ``` sh 10 $ go get github.com/DamienFontaine/lunarc 11 $ cd $GOPATH/src/github.com/DamienFontaine/lunarc 12 $ godep restore 13 ``` 14 15 ## Example 16 17 ### Serve static files 18 19 ``` 20 . 21 +-- config.yml 22 +-- main.go 23 +-- Public 24 | +-- index.html 25 ``` 26 config.yml 27 ```yml 28 production: 29 server: 30 port: 8888 31 ``` 32 main.go 33 ``` go 34 package main 35 36 import ( 37 "log" 38 "net/http" 39 40 "github.com/DamienFontaine/lunarc/web" 41 ) 42 43 func main() { 44 s, err := web.NewServer("config.yml", "production") 45 if err != nil { 46 log.Printf("Error: %v", err) 47 } 48 m := s.Handler.(*web.LoggingServeMux) 49 m.Handle("/", http.FileServer(http.Dir("public/"))) 50 51 go s.Start() 52 53 select { 54 case <-s.Done: 55 return 56 case <-s.Error: 57 log.Println("Error: server terminate") 58 return 59 } 60 } 61 ``` 62 public/index.html 63 ```html 64 <!DOCTYPE html> 65 <html> 66 <head> 67 <title>Example</title> 68 </head> 69 <body> 70 <h1>Hello Wolrd!</h1> 71 </body> 72 </html> 73 ``` 74 Start the server 75 ```sh 76 $ go run main.go 77 ``` 78 79 ## License 80 GNU Affero General Public License version 3: <http://www.gnu.org/licenses/agpl-3.0.txt>