Skip to content

Latest commit

 

History

History
146 lines (106 loc) · 3.48 KB

readme.en.md

File metadata and controls

146 lines (106 loc) · 3.48 KB

Shorten Link

缩短网址,让分享更简单
Shorten Link, Make Sharing Simpler


Live Demo


English | 简体中文


Features

  • ⚡️ qwik Accelerate our SSR application from the source

  • 📦 iris A High Performance, Easy to Use and Powerful Go Language Web Framework

  • 🔎 bolt An efficient, embedded, and persistent key-value storage database, just don't want to use too heavy mysql and redis

  • 🎨 TaliWindCss The Patriarch of the Atomic CSS Framework

  • 😃 daisyui Use Tailwind CSS but write less class names

  • ☁️ Deploy on Netlify, zero-config

  • 🦾 Golang, of course

  • 🦾 TypeScript, of course


Function introduction - qwik part

  • Global variable management

  • I18n multi-language switching

Function introduction - iris part

Record the request log and write it to a local file

{
  "timestamp": "2023-01-21 21:15:03",
  "latency": 405000,
  "code": 200,
  "method": "GET",
  "path": "/ping",
  "ip": "::1",
  "bytes_sent": 4
}

Management side JWT identity verification

app.Post("/login", s.Login)
admin := app.Party("/admin")
{
    admin.UseRouter(jwtMiddle.Serve)
    admin.Post("/flush", s.Flush)
    admin.Get("/all", s.All)
    admin.Post("/del", s.DelOne)
}

Dependent injection(DI) to reduce coupling()

{
...
app.RegisterDependency(shortService)
...
app.ConfigureContainer(func(api *iris.APIContainer) {
  api.Post("/short", s.ShortLink)
  api.Get("/u/{key}", s.GetRaw)
})}
...
func (s ShorterCtl) GetRaw(ctx iris.Context, ss *service.ShorterService) {
	key := ctx.Params().Get("key")
	link, err := ss.GetRaw(key)
	if err != nil {
		CommonResponse{}.Fail().SetData(err.Error()).Send(ctx)
		return
	}
	ctx.Redirect(link, iris.StatusMovedPermanently)
	return
}


### Routing self-test, become a cute backend
```go
var commonSchema = `{
			"type": "object",
			"properties": {
				"code":  {"type": "number"},
				"msg":   {"type": "string"},
				"data":  {"type": ["object","string"]}},
			"required": ["code", "msg", "data"]
		}`
    
func TestAdminApi(t *testing.T) {
	app := NewApp()
	e := httptest.New(t, app)
	e.GET("/admin/all").Expect().Status(httptest.StatusOK).
		JSON().Schema(commonSchema)
}

Relevant information

golang

qwik