Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
small webserver used for developing webapps in go. Will recompile your go program before each request.
Go
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
README.rdoc
error.go
main.go

README.rdoc

Installation

goinstall github.com/tobi/tinny

you may have to add your $GOROOT/bin to your path to access the executable

Usage

tobi@tobbook8 ~  $ tinny --help
Usage of tinny:
  -c="make": compiler to execute. make by default.
  -e="server": executable to launch. Must support -pXXXX for port assignment
  -p=3333: port

Purpose

Tinny is a tiny web server thats used during development. When tinny recieves a request it will launch a compiler task ( such as make ), start an executable in the current directory and then forward the HTTP request to that server.

Requirements

You must be working on a http sever. The http server needs to understand the -pXXXX command line switch that specifies the server it's running on.

Example:

tobi@tobbook8 ~ $ cd ~/Code/go/imagery/src
tobi@tobbook8 ~/Code/go/imagery/src $ tinny -compiler=gb
Listening on port 3333
  -> forwarding to executable server -p4357

Template:

If you are starting a go web project, use this as template:

package main

import (
  "net/http"
  "flag"
  "fmt"
)

var port *int = flag.Int("p", 3333, "http port") 

func HelloServer(w http.ResponseWriter, req *http.Request) {
  w.Header().Set("Content-Type", "text/plain")
  w.Write([]byte("hello, world\n"))
}

func main() {
  flag.Parse()
  http.HandleFunc("/", HelloServer)

  fmt.Printf("Listening on port %d\n", *port)
  err := http.ListenAndServe(fmt.Sprintf(":%d", *port), nil)
  if err != nil {
    panic(err)
  }
}
Something went wrong with that request. Please try again.