https://github.com/soongo/soon
Soon is a web framework written in Go (Golang). It features an Express.js-like API.
https://github.com/soongo/soon
express expressjs framework go golang middleware router server soon soongo
Last synced: 3 months ago
JSON representation
Soon is a web framework written in Go (Golang). It features an Express.js-like API.
- Host: GitHub
- URL: https://github.com/soongo/soon
- Owner: soongo
- License: mit
- Created: 2019-10-21T04:29:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-12-10T13:38:52.000Z (over 5 years ago)
- Last Synced: 2024-06-20T18:54:28.818Z (almost 2 years ago)
- Topics: express, expressjs, framework, go, golang, middleware, router, server, soon, soongo
- Language: Go
- Size: 321 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Soon Web Framework
[](https://github.com/soongo/soon/actions?query=workflow%3Abuild)
[](https://codecov.io/gh/soongo/soon)
[](https://goreportcard.com/report/github.com/soongo/soon)
[](https://godoc.org/github.com/soongo/soon)
[](https://opensource.org/licenses/MIT)
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](https://golang.org/) installed (**version 1.11+ is required**), then you can use the below Go command to install `Soon`.
```sh
$ go get -u github.com/soongo/soon
```
## Quick Start
```go
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")
}
```