All Projects → goa-go → goa

goa-go / goa

Licence: MIT license
Goa is a web framework based on middleware, like koa.js.

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to goa

Goa
Design-based APIs and microservices in Go
Stars: ✭ 4,493 (+9667.39%)
Mutual labels:  goa

Goa

Build Status Codecov Go Doc Go Report Mentioned in Awesome Go PR's Welcome

Goa is under construction, if you are familiar with koa or go and interested in this project, please join us.

What is goa?

goa = go + koa

Just like koa, goa is also not bundled with any middleware. But you can expand functionality to meet your needs at will by middlware. It is flexible, light, high-performance and extensible.

Installation

$ go get -u github.com/goa-go/goa

Hello Goa

func main() {
  app := goa.New()

  app.Use(func(c *goa.Context) {
    c.String("Hello Goa!")
  })
  log.Fatal(app.Listen(":3000"))
}

Middleware

Goa is a web framework based on middleware. Here is an example of using goa-router and logger.

package main

import (
  "fmt"
  "log"
  "time"

  "github.com/goa-go/goa"
  "github.com/goa-go/router"
)

func logger(c *goa.Context) {
  start := time.Now()

  fmt.Printf(
    "[%s] <-- %s %s\n",
    start.Format("2006-01-02 15:04:05"),
    c.Method,
    c.URL,
  )
  c.Next()
  fmt.Printf(
    "[%s] --> %s %s %d %s\n",
    time.Now().Format("2006-01-02 15:04:05"),
    c.Method,
    c.URL,
    time.Since(start).Nanoseconds()/1e6,
    "ms",
  )
}

func main() {
  app := goa.New()
  r := router.New()

  r.GET("/", func(c *goa.Context) {
    c.String("Hello Goa!")
  })

  app.Use(logger)
  app.Use(r.Routes())
  log.Fatal(app.Listen(":3000"))
}

If you are unwilling to use goa-router, you can make a custom router middleware as you like.

Maintainers

@NicholasCao.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].