Skip to content

walkr/gower

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gower

a tiny Go framework

Usage

package main

import (
    "github.com/walkr/gower"
)

// Simple Hello World
func hello(c *gower.Context){
    c.Write("Hello World")
}

// Read the name from url and output a template
func sayHi(c *gower.Context){
    data := map[string]interface{}{"name":c.Matches[1]}
    // Template location "www/templates/say-hi.html"
    c.WriteTemplate("say-hi.html", data)
}

// Display some server stats
func serverStats(c *gower.Context){
	c.WriteJson(gower.ServerStat)
}

func main(){

    // Register the routes
    gower.Get("/hello", hello)
    gower.Get("/say-hi/([a-zA-Z]+)", sayHi)
	 gower.Get("/stats", serverStats)
    // Start the server
    gower.Start()

}
# Start app
./bin/app

# Start on a different port and enable debug
./bin/app --port=9000 --debug=true

MIT License

About

A tiny go framework

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages