Example #1
0
	"github.com/eaciit/kingpin"
	"github.com/eaciit/knot"
	"io/ioutil"
	//"os"
	"path/filepath"
	"reflect"
	"strings"
	// -- KnotApp Registration Start
	// -- KnotAppRegistration End
)

var (
	apps = map[string]*App{}
	ks   *knot.Server

	flagAddress = kingpin.Flag("address",
		"Address to be used by Knot Server. It normally formatted as SERVERNAME:PORTNUMBER").Default("localhost:9876").String()
)

type App struct {
	Name           string
	Enable         bool
	LayoutTemplate string
	ViewsPath      string

	controllers map[string]interface{}
	statics     map[string]string
}

func (a *App) Register(c interface{}) error {
	v := reflect.ValueOf(c)
	if v.Kind() != reflect.Ptr {
Example #2
0
File: main.go Project: eaciit/sebar
package main

import (
	"fmt"
	"github.com/eaciit/kingpin"
	"github.com/eaciit/knot"
	//"net/http"
)

var (
	port = kingpin.Flag("port", "Port to be used to listen for request").Default("13000").String()
	e    error
)

func main() {
	kingpin.Parse()

	ks := new(knot.Server)
	ks.Address = ":" + *port
	ks.Route("/", Index)
	e = ks.Register(new(ServerController), "")
	if e != nil {
		fmt.Println("Error: " + e.Error())
		return
	}

	ks.Listen()
}

func Index(r *knot.Request) interface{} {
	return "Welcome to Sebar Server"