Giter VIP home page Giter VIP logo

goumiweb's Introduction

Goumi

Goumi is a very simple way to build modular applications. It improves on the net/http and tries to be as minimal as possible. It is inspired by KoaJS.

Getting Started

After installing Go and setting up your GOPATH, create your first .go file. We'll call it server.go.

package main

import (
  "fmt"
  "github.com/goumi/web"
  "github.com/goumi/logger"
  "github.com/goumi/mount"
  "net/http"
)

func main() {

  // Setup the app
  m := web.New()

  // Logger
  m.Use(logger.New())

  // Router
  mux := http.NewServeMux()
  mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
    fmt.Fprintf(w, "Welcome to Goumi!")
  })
  m.Use(web.HTTPHandler(mux))

  // Mount another application
  mw := web.New()

  // Run another middleware
  mw.Use(web.HandlerFunc(func(ctx Context) {

    // Do your stuff
    ctx.Response().Header().Add("X-Powered-By", "Goumi")

    // Call next middlware
    ctx.Next()

    // You can do something else after the stack has run
    ctx.Response().Write([]byte("Hello!"))
  }))

  // Mount it on hello
  m.Use(mount.New("/hello", mw))

  // Run the server
  http.ListenAndServe(":3000", m)
}

Then install the Goumi package (go 1.3 and greater is required):

go get github.com/claudiuandrei/goumi

Then run your server:

go run server.go

You will now have a Go net/http webserver running on localhost:3000.

Use() - Middleware & Routing

Goumi Use function adds middleware to the request execution chain. Everything that acts like a Handler can be a middleware and will run through each of them in the order added as long as there context Next() function is called.

Goumi is BYOR (Bring your own Router). Goumi is fully supporting net/http.

Authors

Claudiu Andrei

TODO

  • Docs
  • Tests
  • Errors
  • Recovery

Midleware

  • Logger
  • Server
  • Static
  • Router
  • Session
  • Templates (Pongo2)

goumiweb's People

Contributors

claudiuandrei avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.