Adapter Development
The role of the adapter is to achieve the conversion of the web framework context and GoAdmin's own context. To make a Adapter, you need implemente three methods:
1
package adapter
2
3
import (
4
"github.com/GoAdminGroup/go-admin/plugins"
5
"github.com/GoAdminGroup/go-admin/template/types"
6
)
7
// WebFrameWork is an interface which is used as an adapter of
8
// framework and goAdmin. It must implement two methods. Use registers
9
// the routes and the corresponding handlers. Content writes the
10
// response to the corresponding context of framework.
11
type WebFrameWork interface {
12
// Name return the web framework name.
13
Name() string
14
15
// Use method inject the plugins to the web framework engine which is the
16
// first parameter.
17
Use(app interface{}, plugins []plugins.Plugin) error
18
19
// Content add the panel html response of the given callback function to
20
// the web framework context which is the first parameter.
21
Content(ctx interface{}, fn types.GetPanelFn, navButtons ...types.Button)
22
23
// User get the auth user model from the given web framework context.
24
User(ctx interface{}) (models.UserModel, bool)
25
26
// AddHandler inject the route and handlers of GoAdmin to the web framework.
27
AddHandler(method, path string, handlers context.Handlers)
28
29
DisableLog()
30
31
Static(prefix, path string)
32
33
// Helper functions
34
// ================================
35
36
SetApp(app interface{}) error
37
SetConnection(db.Connection)
38
GetConnection() db.Connection
39
SetContext(ctx interface{}) WebFrameWork
40
GetCookie() (string, error)
41
Path() string
42
Method() string
43
FormParam() url.Values
44
IsPjax() bool
45
Redirect()
46
SetContentType()
47
Write(body []byte)
48
CookieKey() string
49
HTMLContentType() string
50
}
Copied!
Last modified 1yr ago
Copy link