Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krishpranav/flash
A golang frontend web framework
https://github.com/krishpranav/flash
backend frontend go golang rest-api restapi socket web web-framework webframework
Last synced: about 1 month ago
JSON representation
A golang frontend web framework
- Host: GitHub
- URL: https://github.com/krishpranav/flash
- Owner: krishpranav
- License: gpl-2.0
- Created: 2022-07-13T11:14:21.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-13T12:18:10.000Z (over 2 years ago)
- Last Synced: 2024-10-16T20:06:52.132Z (3 months ago)
- Topics: backend, frontend, go, golang, rest-api, restapi, socket, web, web-framework, webframework
- Language: Go
- Homepage:
- Size: 20.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# flash
A golang frontend web framework[![forthebadge](https://forthebadge.com/images/badges/made-with-go.svg)](https://forthebadge.com)
## Features:
- Fast ⚡
- Easy To Use 🙂
- Cross Platform 💻## Installation:
```
$ go get -u https://github.com/krishpranav/flash
```## Usage:
- import flash into your project:
```golang
import "github.com/krishpranav/flash"
```- form view:
```golang
package mainimport (
"strconv""github.com/krishpranav/flash"
)type People struct {
Names []string
Name string
}func (c *People) Render() (string, error) {
return `
{{ range $i, $name := .Names }}
{{ $name }}
Delete
{{ end }}
Add name:
Add
`, nil
}func (c *People) Delete(key string) {
index, _ := strconv.Atoi(key)
c.Names = append(c.Names[:index], c.Names[index+1:]...)
}func (c *People) Add() {
c.Names = append(c.Names, c.Name)
c.Name = ""
}func main() {
panic(flash.NewServer().Start(func(_ *flash.Connection) flash.Component {
return &People{
Names: []string{"NameOne", "NameTwo"},
}
}))
}
```- clock view:
```golang
package mainimport (
"time""github.com/krishpranav/flash"
)type Clock struct{}
func (c *Clock) Render() (string, error) {
return `
The time now is {{ call.Now }}.
`, nil
}func (c *Clock) Now() string {
return time.Now().Format(time.RFC1123)
}func main() {
panic(flash.NewServer().Start(func(conn *flash.Connection) flash.Component {
go func() {
for range time.NewTicker(time.Second).C {
conn.Update()
}
}()return &Clock{}
}))
}```
- counter view:
```golang
package mainimport "github.com/krishpranav/flash"
type Counter struct {
Number int
}func (c *Counter) Render() (string, error) {
return `
Counter: {{ .Number }}
+
`, nil
}func (c *Counter) AddOne() {
c.Number++
}func main() {
panic(flash.NewServer().Start(func(_ *flash.Connection) flash.Component {
return &Counter{}
}))
}```
## License:
- flash is licensed under [GPL-2.0 License](https://github.com/krishpranav/flash/blob/main/LICENSE)