-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
699 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.buildpath | ||
.hgignore.swp | ||
.project | ||
.orig | ||
.swp | ||
.idea/ | ||
.settings/ | ||
.vscode/ | ||
vendor/ | ||
composer.lock | ||
gitpush.sh | ||
pkg/ | ||
bin/ | ||
cbuild | ||
**/.DS_Store | ||
.vscode/ | ||
.test/ | ||
main | ||
output/ | ||
manifest/output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 yoby | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# goframe2.0例子 | ||
编译 | ||
go build | ||
访问 | ||
http://127.0.0.1:8000/hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package v1 | ||
|
||
import ( | ||
"github.com/gogf/gf/v2/frame/g" | ||
) | ||
|
||
type HelloReq struct { | ||
g.Meta `path:"/hello" tags:"Hello" method:"get" summary:"You first hello api"` | ||
} | ||
type HelloRes struct { | ||
g.Meta `mime:"text/html" example:"string"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module gflay | ||
|
||
go 1.15 | ||
|
||
require ( | ||
github.com/gogf/gf/v2 v2.0.0-rc.0.20220117131058-9345eb5e946f | ||
github.com/logoove/sqlite v1.13.0 | ||
github.com/russross/blackfriday/v2 v2.1.0 | ||
modernc.org/sqlite v1.15.3 // indirect | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
|
||
"gflay/internal/controller" | ||
"github.com/gogf/gf/v2/frame/g" | ||
"github.com/gogf/gf/v2/net/ghttp" | ||
"github.com/gogf/gf/v2/os/gcmd" | ||
_ "github.com/logoove/sqlite" | ||
) | ||
|
||
var ( | ||
Main = gcmd.Command{ | ||
Name: "main", | ||
Usage: "main", | ||
Brief: "start http server", | ||
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { | ||
s := g.Server() | ||
s.Group("/", func(group *ghttp.RouterGroup) { | ||
group.Middleware(ghttp.MiddlewareHandlerResponse) | ||
group.Bind( | ||
controller.Hello, | ||
) | ||
}) | ||
s.Run() | ||
return nil | ||
}, | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package consts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package controller | ||
|
||
import ( | ||
"context" | ||
"gflay/api/v1" | ||
|
||
"github.com/gogf/gf/v2/frame/g" | ||
) | ||
|
||
var ( | ||
Hello = cHello{} | ||
) | ||
|
||
type cHello struct{} | ||
|
||
func (h *cHello) Hello(ctx context.Context, req *v1.HelloReq) (res *v1.HelloRes, err error) { | ||
id, _ := g.Model("user").Data(g.Map{"name": "john", "age": 1}).InsertAndGetId() | ||
g.RequestFromCtx(ctx).Response.Writeln("Hello World!", id) | ||
return | ||
} |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package packed |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package main | ||
|
||
import ( | ||
_ "gflay/internal/packed" | ||
|
||
"github.com/gogf/gf/v2/os/gctx" | ||
"gflay/internal/cmd" | ||
) | ||
|
||
func main() { | ||
cmd.Main.Run(gctx.New()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
server: | ||
address: ":8000" | ||
openapiPath: "/api.json" | ||
swaggerPath: "/swagger" | ||
serverRoot: "resource/public" | ||
dumpRouterMap: true | ||
routeOverWrite: true | ||
accessLogEnabled: false | ||
accessLogPattern: "access-{Ymd}.log" | ||
sessionPath: "./temp/sessions" # Session文件存储目录 | ||
logger: | ||
level : "all" | ||
stdout: true | ||
path: "./temp/logs/default" | ||
ctxKeys: ["RequestId"] | ||
# 数据库连接配置 | ||
database: | ||
logger: | ||
path: "./temp/logs/sql" | ||
level: "all" | ||
stdout: true | ||
ctxKeys: ["RequestId"] | ||
|
||
default: | ||
type: "sqlite" | ||
# link: "mysql:root:mysql@tcp(127.0.0.1:3306)/gflay" | ||
link: "./resource/db.db" | ||
debug: true | ||
# 模板引擎配置 | ||
viewer: | ||
indexLayout: "index/index.html" | ||
adminHomeLayout: "admin/home.html" | ||
adminLayout: "admin/index.html" | ||
# 内容设置 | ||
setting: | ||
title: "拾人拾物" | ||
keywords: "寻人寻物" | ||
description: "寻人寻物平台" | ||
adminId: 1 # 管理员ID | ||
|
||
# 文件上传设置 | ||
upload: | ||
path: "upload" |
21 changes: 21 additions & 0 deletions
21
examples/gflay/manifest/deploy/kustomize/base/deployment.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: template-single | ||
labels: | ||
app: template-single | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: template-single | ||
template: | ||
metadata: | ||
labels: | ||
app: template-single | ||
spec: | ||
containers: | ||
- name : main | ||
image: template-single | ||
imagePullPolicy: Always | ||
|
8 changes: 8 additions & 0 deletions
8
examples/gflay/manifest/deploy/kustomize/base/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- deployment.yaml | ||
- service.yaml | ||
|
||
|
||
|
12 changes: 12 additions & 0 deletions
12
examples/gflay/manifest/deploy/kustomize/base/service.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: template-single | ||
spec: | ||
ports: | ||
- port: 80 | ||
protocol: TCP | ||
targetPort: 8000 | ||
selector: | ||
app: template-single | ||
|
14 changes: 14 additions & 0 deletions
14
examples/gflay/manifest/deploy/kustomize/overlays/develop/configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: template-single-configmap | ||
data: | ||
config.yaml: | | ||
server: | ||
address: ":8000" | ||
openapiPath: "/api.json" | ||
swaggerPath: "/swagger" | ||
logger: | ||
level : "all" | ||
stdout: true |
10 changes: 10 additions & 0 deletions
10
examples/gflay/manifest/deploy/kustomize/overlays/develop/deployment.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: template-single | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name : main | ||
image: template-single:develop |
14 changes: 14 additions & 0 deletions
14
examples/gflay/manifest/deploy/kustomize/overlays/develop/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
resources: | ||
- ../../base | ||
- configmap.yaml | ||
|
||
patchesStrategicMerge: | ||
- deployment.yaml | ||
|
||
namespace: default | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM loads/alpine:3.8 | ||
|
||
############################################################################### | ||
# INSTALLATION | ||
############################################################################### | ||
|
||
ENV WORKDIR /app | ||
|
||
ADD resource $WORKDIR/ | ||
|
||
ADD ./bin/linux_amd64/main $WORKDIR/main | ||
|
||
RUN chmod +x $WORKDIR/main | ||
|
||
############################################################################### | ||
# START | ||
############################################################################### | ||
WORKDIR $WORKDIR | ||
CMD ./main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
# This shell is executed before docker build. | ||
|
||
|
||
|
||
|
||
|
Binary file not shown.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package response | ||
|
||
import ( | ||
"github.com/gogf/gf/v2/frame/g" | ||
"github.com/gogf/gf/v2/net/ghttp" | ||
) | ||
|
||
// JsonRes 数据返回通用JSON数据结构 | ||
type JsonRes struct { | ||
Code int `json:"code"` // 错误码((0:成功, 1:失败, >1:错误码)) | ||
Message string `json:"message"` // 提示信息 | ||
Data interface{} `json:"data"` // 返回数据(业务接口定义具体数据结构) | ||
Redirect string `json:"redirect"` // 引导客户端跳转到指定路由 | ||
} | ||
|
||
// Json 返回标准JSON数据。 | ||
func Json(r *ghttp.Request, code int, message string, data ...interface{}) { | ||
var responseData interface{} | ||
if len(data) > 0 { | ||
responseData = data[0] | ||
} else { | ||
responseData = g.Map{} | ||
} | ||
r.Response.WriteJson(JsonRes{ | ||
Code: code, | ||
Message: message, | ||
Data: responseData, | ||
}) | ||
} | ||
|
||
// JsonExit 返回标准JSON数据并退出当前HTTP执行函数。 | ||
func JsonExit(r *ghttp.Request, code int, message string, data ...interface{}) { | ||
Json(r, code, message, data...) | ||
r.Exit() | ||
} | ||
|
||
// JsonRedirect 返回标准JSON数据引导客户端跳转。 | ||
func JsonRedirect(r *ghttp.Request, code int, message, redirect string, data ...interface{}) { | ||
responseData := interface{}(nil) | ||
if len(data) > 0 { | ||
responseData = data[0] | ||
} | ||
r.Response.WriteJson(JsonRes{ | ||
Code: code, | ||
Message: message, | ||
Data: responseData, | ||
Redirect: redirect, | ||
}) | ||
} | ||
|
||
// JsonRedirectExit 返回标准JSON数据引导客户端跳转,并退出当前HTTP执行函数。 | ||
func JsonRedirectExit(r *ghttp.Request, code int, message, redirect string, data ...interface{}) { | ||
JsonRedirect(r, code, message, redirect, data...) | ||
r.Exit() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package utils | ||
|
||
import ( | ||
"github.com/russross/blackfriday/v2" | ||
) | ||
|
||
// MarkdownToHtml 解析markdown为html | ||
func MarkdownToHtml(mdContent string) string { | ||
return string(blackfriday.Run([]byte(mdContent))) | ||
} |
Oops, something went wrong.