package module
v0.0.0-...-955f5c7 Latest Latest

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

Go to latest
Published: Sep 14, 2015 License: MIT Imports: 4 Imported by: 1



What is fur ?

fur is just a simple web server api, to make things less repetitive. No revolution of any kind in this package, just a simple way to build your Web application basics. fur isn't trying to be a framework at all! It is more of a toolkit (e.g Gorilla).


  • Support URL Variables fur.AddRoute("/home/:id", Handler)

  • Remove the log argument from fur.NewServer(), you can use your own logger or if you need a simple one you can use middle.Logger(). You just have to use it in fur.Stack(), if you want to use it on every handler.

  • Now you can provide your own Multiplexer, you just need to implement the simple Plex interface. If you want to use bone which support url variables, you can use fur.NewServerMux()instead of fur.NewServer().


  • Middleware Chaining.
  • Global Middleware declaration.
  • Shorter version, for static file serving.
  • Server instance as a Struct.
  • Force a HTTP method on a route.
  • Chaining Options on the Server at Creation.
  • Simple Context Struct

alt tag


package main

import "github.com/squiidz/fur"

func main() {
	// You can use ` fur.NewServerMux() ` if you want the default ` bone.Mux `.
	server := fur.NewServer("localhost", ":8080", yourMux, option1, option2)
	// Set Global Middleware

	// Serve Static files
	server.AddStatic("/public/", "../public")

	// Add multiple routes with chaining middleware, http Method and url variables
	server.AddRoute("/home", HomeHandler, Middleware1, Middleware2)
	server.AddRoute("/home/:id", DefaultHandler, MiddleWare3).Get()
	server.AddRoute("/data", DataHandler).Post()

	// Start Listening

// Get the :id value
func GetUrlVar(rw http.ResponseWriter, req *http.Request) {
	value := req.URL.Query().Get("id")

Middlewares and Options

Every function that has the signature func (next http.Handler) http.Handler can be passed as a MiddleWare. Or pass a func (rw http.ResponseWriter, req *http.Request) to fur.Mutate().

Every function that has the signature func (s *fur.Server) can be passed as a Option.


  • Import github.com/squiidz/fur/context

  • Create a New Context with cont := context.NewContext(req)

  • Set some Key/Value cont.Set("key", "value")

  • Find the already created context cont := context.FindContext(req)

  • Retrive the key cont.Get("key")

  • Check the example folder if you want to see it in action.

Next features

  • Context Variables [DONE]
  • Shortway static files serving [DONE]
  • Add Global Middleware [DONE]
  • Force HTTP method on Route [DONE]
  • Refactoring


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Write Tests!
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request






This section is empty.


This section is empty.


func GetValue

func GetValue(req *http.Request, key string) string

func Mutate

func Mutate(h http.HandlerFunc) func(http.Handler) http.Handler

transform Normal handler into middleware


type Plex

type Plex interface {
	Handle(string, http.Handler)
	ServeHTTP(http.ResponseWriter, *http.Request)

type Server

type Server struct {
	Host string
	Port string
	// contains filtered or unexported fields

Simple Server structure for a web server.

func NewServer

func NewServer(host string, port string, p Plex, options ...func(s *Server)) *Server

Create a NewServer instance with the given value. Host: "localhost" Port: ":8080" mux: Any Type which implement Plex (http.NewServeMux(), bone.NewMux() etc..) Options: functions to run on the server instance who's gonna be return.

func NewServerMux

func NewServerMux(host string, port string, options ...func(s *Server)) *Server

Create a NewServer instance with the default http.NewServeMux(). Host: "localhost" Port: ":8080" Options: functions to run on the server instance who's gonna be return.

func (*Server) AddRoute

func (s *Server) AddRoute(path string, f func(rw http.ResponseWriter, req *http.Request), middles ...interface{}) *bone.Route

Add function with the right sigature to the Server Mux and chain the provided middlewares on it.

func (*Server) AddStatic

func (s *Server) AddStatic(path string, dir string)

Temporary way for serving static files

func (*Server) Stack

func (s *Server) Stack(middles ...interface{})

Add Global Middleware to origin

func (*Server) Start

func (s *Server) Start()

Start Listening on host and port of the Server. Log the request if the log was initiated as true in NewServer.


Path Synopsis

Jump to

Keyboard shortcuts

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