lunarc

module
v0.0.0-...-2e7332a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2019 License: AGPL-3.0

README

Lunarc

Build Status Coverage Status GoDoc

Download and install

$ go get github.com/DamienFontaine/lunarc
$ cd $GOPATH/src/github.com/DamienFontaine/lunarc
$ godep restore

Example

Serve static files
.
+-- config.yml
+-- main.go
+-- Public
|   +-- index.html

config.yml

production:
  server:
    port: 8888

main.go

package main

import (
	"log"
	"net/http"

	"github.com/DamienFontaine/lunarc/web"
)

func main() {
	s, err := web.NewServer("config.yml", "production")
	if err != nil {
		log.Printf("Error: %v", err)
	}
	m := s.Handler.(*web.LoggingServeMux)
	m.Handle("/", http.FileServer(http.Dir("public/")))

	go s.Start()

	select {
	case <-s.Done:
		return
	case <-s.Error:
		log.Println("Error: server terminate")
		return
	}
}

public/index.html

<!DOCTYPE html>
<html>
  <head>
<title>Example</title>
  </head>
  <body>
    <h1>Hello Wolrd!</h1>
  </body>
</html>

Start the server

$ go run main.go

License

GNU Affero General Public License version 3: http://www.gnu.org/licenses/agpl-3.0.txt

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL