# README
gFly Core - Core Web written in Go
Copyright © 2023, gFly
https://www.gfly.dev
All rights reserved.
Setup gFly Core
mkdir myweb && cd myweb
go mod init myweb
go get -u github.com/gflydev/core@latest
Play with gFly
Create folder
Inside your application folder myweb
mkdir -p storage/tmp
mkdir -p storage/logs
mkdir -p storage/app
mkdir -p resources/views
mkdir -p resources/tls
Create static page
mkdir public
touch public/index.html
Content index.html
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<title>gFly | Laravel inspired web framework written in Go</title>
</head>
<body>
<h2>gFly | Laravel inspired web framework written in Go</h2>
</body>
</html>
Create app main.go
package main
import (
"fmt"
"github.com/gflydev/core"
"github.com/gflydev/core/utils"
_ "github.com/joho/godotenv/autoload"
)
// =========================================================================================
// Default API
// =========================================================================================
// NewDefaultApi As a constructor to create new API.
func NewDefaultApi() *DefaultApi {
return &DefaultApi{}
}
// DefaultApi API struct.
type DefaultApi struct {
core.Api
}
func (h *DefaultApi) Handle(c *core.Ctx) error {
return c.JSON(core.Data{
"name": core.AppName,
"server": core.AppURL,
})
}
// =========================================================================================
// Home page
// =========================================================================================
// NewHomePage As a constructor to create a Home Page.
func NewHomePage() *HomePage {
return &HomePage{}
}
type HomePage struct {
core.Page
}
func (m *HomePage) Handle(c *core.Ctx) error {
return c.HTML("<h2>Hello world</h2>")
}
// =========================================================================================
// Routers
// =========================================================================================
func router(g core.IFlyRouter) {
prefixAPI := fmt.Sprintf(
"/%s/%s",
utils.Getenv("API_PREFIX", "api"),
utils.Getenv("API_VERSION", "v1"),
)
// API Routers
g.Group(prefixAPI, func(apiRouter *core.Group) {
apiRouter.GET("/info", NewDefaultApi())
})
// Web Routers
g.GET("/home", NewHomePage())
}
// =========================================================================================
// Application
// =========================================================================================
func main() {
app := core.New()
// Register middleware
//app.RegisterMiddleware(hookMiddlewares)
// Register router
app.RegisterRouter(router)
app.Run()
}
Run and Check
Run
go run main.go
Check API
curl -X 'GET' \
'http://localhost:7789/api/v1/info' | jq
Note: Install jq tool to view JSON format
Check static page http://localhost:7789/index.html
Check dynamic page http://localhost:7789/home
# Functions
New Create new gFly app.
No description provided by the author
NewRouter returns a new router.
NewTree returns an empty routes storage.
RegisterSession Get data from session.
RegisterView inject View.
# Constants
Cookie SameSite.
Cookie SameSite.
Cookie SameSite.
Cookie SameSite.
GlobalIpv4Addr Global IPv4.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
Deprecated: use HeaderPermissionsPolicy instead.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
RFC 7231, 4.3.6.
RFC 7231, 4.3.5.
RFC 7231, 4.3.1.
RFC 7231, 4.3.2.
RFC 7231, 4.3.7.
RFC 5789.
RFC 7231, 4.3.3.
RFC 7231, 4.3.4.
RFC 7231, 4.3.8.
HTTP methods were copied from net/http.
MethodWild wild HTTP method.
MIME types that are commonly used.
Deprecated: use MIMETextJavaScript instead.
Deprecated: use MIMETextJavaScriptCharsetUTF8 instead.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
NetworkTCP Network TCP.
NetworkTCP4 Network TCP4.
NetworkTCP6 Network TCP6.
SchemaHTTP HTTP schema.
SchemaHTTPS HTTPS schema.
RFC 9110, 15.3.3.
RFC 5842, 7.1.
RFC 9110, 15.6.3.
RFC 9110, 15.5.1.
RFC 9110, 15.5.10.
RFC 9110, 15.2.1.
RFC 9110, 15.3.2.
RFC 8297.
RFC 9110, 15.5.18.
RFC 4918, 11.4.
RFC 9110, 15.5.4.
RFC 9110, 15.4.3.
RFC 9110, 15.6.5.
RFC 9110, 15.5.11.
RFC 9110, 15.6.6.
RFC 3229, 10.4.1.
RFC 4918, 11.5.
RFC 9110, 15.6.1.
RFC 9110, 15.5.12.
RFC 4918, 11.3.
RFC 5842, 7.2.
RFC 9110, 15.5.6.
RFC 9110, 15.5.20.
RFC 9110, 15.4.2.
RFC 9110, 15.4.1.
RFC 4918, 11.1.
RFC 6585, 6.
RFC 9110, 15.3.5.
RFC 9110, 15.3.4.
RFC 9110, 15.5.7.
RFC 2774, 7.
RFC 9110, 15.5.5.
RFC 9110, 15.6.2.
RFC 9110, 15.4.5.
RFC 9110, 15.3.1.
RFC 9110, 15.3.7.
RFC 9110, 15.5.3.
RFC 9110, 15.4.9.
RFC 9110, 15.5.13.
RFC 6585, 3.
RFC 2518, 10.1.
RFC 9110, 15.5.8.
RFC 9110, 15.5.17.
RFC 9110, 15.5.14.
RFC 6585, 5.
RFC 9110, 15.5.9.
RFC 9110, 15.5.15.
RFC 9110, 15.3.6.
RFC 9110, 15.4.4.
RFC 9110, 15.6.4.
RFC 9110, 15.2.2.
RFC 9110, 15.4.7 (Unused).
RFC 9110, 15.5.19 (Unused).
RFC 9110, 15.4.8.
RFC 8470, 5.2.
RFC 6585, 4.
RFC 9110, 15.5.2.
RFC 7725, 3.
RFC 9110, 15.5.21.
RFC 9110, 15.5.16.
RFC 9110, 15.5.22.
RFC 9110, 15.4.6.
RFC 2295, 8.1.
Compression types.
Compression types.
Compression types.
Compression types.
Version of current gFly.
# Variables
No description provided by the author
No description provided by the author
Directory `{APP}/storage/app`.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Directory `{APP}/storage/log`.
Directory `{APP}/storage`.
Directory `{APP}/storage/temp`.
# Structs
Api Abstract api.
No description provided by the author
Ctx HTTP request context.
No description provided by the author
No description provided by the author
Endpoint Default handler.
GFly Struct define main elements in app.
Group is a sub-router to group paths.
Middleware Middleware type.
Page Abstract web page.
Router is a RequestHandler which can be used to dispatch requests to different handler functions via configurable routes.
Tree is a routes storage.
UploadedFile uploaded file info.
# Interfaces
No description provided by the author
IFly Interface to declare all methods for gFly struct.
IFlyMiddleware Interface to declare all Middleware methods for gFly struct.
IFlyRouter Interface to declare all HTTP methods for gFly struct.
IGroupMiddleware Interface to declare all Middleware methods for gFly struct.
IGroupRouter Interface to declare all HTTP methods.
IHandler Interface a handler request.
No description provided by the author
IMiddleware Middleware interface.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
JsonData generic JSON data type for almost usage purpose.
# Type aliases
Data generic map type for almost usage purpose.
No description provided by the author
No description provided by the author
Map generic map type for almost usage purpose.
MiddlewareHandler must return RequestHandler for continuing or error to stop on it.
RequestHandler A wrapper of fasthttp.RequestHandler.