https://github.com/haquenafeem/gorocks
Experimental web framework written in golang
https://github.com/haquenafeem/gorocks
api experimental framework http-server
Last synced: 7 months ago
JSON representation
Experimental web framework written in golang
- Host: GitHub
- URL: https://github.com/haquenafeem/gorocks
- Owner: haquenafeem
- Created: 2023-12-21T05:20:32.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-22T05:32:14.000Z (over 2 years ago)
- Last Synced: 2025-03-14T00:12:54.117Z (about 1 year ago)
- Topics: api, experimental, framework, http-server
- Language: Go
- Homepage: https://github.com/haquenafeem/gorocks
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# GOROCKS
A simple web framework.
## Notes
- Experimental
- Needs Work
## Example
```go
package main
import (
"fmt"
"net/http"
"time"
"github.com/haquenafeem/gorocks"
)
func main() {
app := gorocks.New()
// If you want your response to be of json type; "Content-Type":"application/json"
app.Use(gorocks.ApplicationJSON)
app.Use(TimeTaken)
app.Get("/", func(a *gorocks.App) {
app.JSON(http.StatusOK, gorocks.Map{
"message": "ok",
})
})
if err := app.Run(":9000"); err != nil {
panic(err)
}
}
// TimeTaken
// Middleware
func TimeTaken(next gorocks.HandlerFunc) gorocks.HandlerFunc {
return func(app *gorocks.App) {
now := time.Now()
next(app)
passed := time.Since(now)
out := fmt.Sprintf("time taken to complete %s is %v", app.HttpRequest().URL.Path, passed.Seconds())
fmt.Println(out)
}
}
// test by curl localhost:9000
// output :
// {
// "message": "ok"
// }
```
More Example Here