Skip to content
/ soon Public

Soon is a web framework written in Go (Golang). It features an Express.js-like API.

License

Notifications You must be signed in to change notification settings

soongo/soon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Soon Web Framework

Build Status codecov Go Report Card GoDoc License

Soon is a web framework written in Go (Golang). It features an expressjs-like API.

Installation

To install Soon, you need to install Go and set your Go workspace first.

The first need Go installed (version 1.11+ is required), then you can use the below Go command to install Soon.

$ go get -u github.com/soongo/soon

Quick Start

package main

import (
	"github.com/soongo/soon"
)

// an example middleware
func logger(c *soon.Context) {
	// do something before
	c.Next()
	// do something after
}

func main() {
	// soon.SetMode(soon.DebugMode) // enable soon framework debug mode

	// Create an app with default router
	app := soon.New()

	app.Use(logger) // use middleware

	app.GET("/", func(c *soon.Context) {
		c.Send("Hello World")
	})

	app.GET("/:foo", func(c *soon.Context) {
		c.Send(c.Params().Get("foo"))
	})

	// an example error handler
	app.Use(func(v interface{}, c *soon.Context) {
		msg := "Internal Server Error"
		switch err := v.(type) {
		case error:
			msg = err.Error()
		case string:
			msg = err
		}
		c.Status(500)
		c.Send(msg)
	})

	app.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}

Releases

No releases published

Packages

No packages published