controllers

package
v0.0.0-...-2403d1f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2017 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PRoot = "/"

	PFiles = "/files"

	PRecodes = "/domain/:did/recodes"
	PRecode  = "/recode/:rid"
	PLogin   = "/login"
	PLogout  = "/logout"
	PAbout   = "/about"

	PDomains = "/domains"
	PDomain  = "/domain/:did"

	PUpdate = "/update"

	PDownloads   = "/downloads"
	PDownloadDel = "/download/del"

	PRRecodes    = "/api/recodes"
	PDataversion = "/api/dataversion"
	PApiUpdate   = "/api/update"
)
View Source
const (
	CodeOK                 = "ok"
	CodeInvalidSession     = "InvalidSession"
	CodeDBError            = "DBError"
	CodeUnknowError        = "UnknowError"
	CodeInvalidParam       = "InvalidParam"
	CodeRecodeExist        = "RecodeExist"
	CodeKeyIsEmpty         = "KeyIsEmpty"
	CodeInvalidIP          = "InvalidIP"
	CodeNoAuthorization    = "NoAuthorization"
	CodeAuthorizationError = "AuthorizationError"
	CodeVerifySignature    = "VerifySignature"
	CodeGetSecretKeyError  = "GetSecretKeyError"
	CodeUserNameError      = "UserNameError"
	CodePasswordError      = "PasswordError"
	CodeInvalidURL         = "InvalidURL"
)
View Source
const (
	MwUserid    = "UserID"
	MwSecretKey = "secretKey"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiCtrl

type ApiCtrl struct {
	ContrllerBase
}

func (ApiCtrl) ApiGetDataSchemaVersion

func (a ApiCtrl) ApiGetDataSchemaVersion()

ApiGetDataSchemaVersion -> [POST] :/api/dataversion

Ret Code:[200]

成功返回值

{
	"code": "OK",
	"version": "0.1"
}

失败返回值

code: xxx

func (ApiCtrl) ApiGetRecodes

func (a ApiCtrl) ApiGetRecodes()

ApiGetRecodes -> [POST] :/api/recodes

Ret Code:[200]

成功返回值

{
	"code": "OK",
	"domains": [
		{
			"id" : xxx,
			"domain": "xxxx",
			"recodes": [
				{
					"id" : xxx,
					"value": "xxxx",
					"type":	type,
					"name":	"name"
					"ttl": xxx,
					"dynamic": true,
					"key": "xxxx"
				}
			]
		}
	]
}

失败返回值

code: xxx

func (ApiCtrl) ApiUpdateRecode

func (a ApiCtrl) ApiUpdateRecode()

ApiUpdateRecode -> [POST] :/api/update

Ret Code:[200]

更新一个记录

成功返回值

{
	"result": "ok"
}

失败返回值

{
	"result": "xxx"
}

type AppCtrl

type AppCtrl struct {
	ContrllerBase
}

func (AppCtrl) GetAbout

func (a AppCtrl) GetAbout()

GetAbout -> [GET] :/about

Ret Code:[200]

func (AppCtrl) GetLogin

func (a AppCtrl) GetLogin()

GetLogin -> [GET] :/login

Ret Code:[200]

func (AppCtrl) Login

func (a AppCtrl) Login()

Login -> [POST] :/login?to=xxxx

Ret Code:[200]

成功返回值

{
	"code": "OK"
}

失败返回值

code: xxx

func (AppCtrl) Logout

func (a AppCtrl) Logout()

Logout -> [POST] :/logout

Ret Code:[200]

成功返回值

{
	"code": "OK"
}

失败返回值

code: xxx

func (AppCtrl) Root

func (a AppCtrl) Root()

Root ...

type ContrllerBase

type ContrllerBase struct {
	*server.CtrlBase
}

func (ContrllerBase) CookieAuthMiddleware

func (h ContrllerBase) CookieAuthMiddleware()

func (ContrllerBase) HTML

func (c ContrllerBase) HTML(code int, params JsonMap)

func (ContrllerBase) JSON

func (c ContrllerBase) JSON(code int, data JsonMap)

func (ContrllerBase) SignMiddleware

func (c ContrllerBase) SignMiddleware()

SignMiddleware 检查API签名 如果成功,会向context中写入secretkey字段

type DomainsCtrl

type DomainsCtrl struct {
	ContrllerBase
}

func (DomainsCtrl) DeleteDomain

func (h DomainsCtrl) DeleteDomain()

DeleteDomain -> [DELETE] :/domain/:did

Ret Code:[200]

删除一个domain

成功返回值

{
	"result": "ok"
}

失败返回值

{
	"result": "xxx"
}

func (DomainsCtrl) DeleteRecode

func (h DomainsCtrl) DeleteRecode()

DeleteRecode -> [DELETE] :/recode/:id

Ret Code:[200]

删除一条记录

成功返回值

{
	"result": "ok"
}

失败返回值

{
	"result": "xxx"
}

func (DomainsCtrl) GetDomain

func (h DomainsCtrl) GetDomain()

GetDomain ....

func (DomainsCtrl) GetDomains

func (d DomainsCtrl) GetDomains()

GetDomains -> [GET] :/domains?r=true&offset=10&limit=0

Ret Code:[200]

[request=json] 获取指定区间的记录数 [request=html] 获取域名列表页面

成功返回值

{
	"code": "OK"
	"domains" : [
		"id": id,
		"domain"; "domain"
	]
}

失败返回值

code: xxx

func (DomainsCtrl) GetRecode

func (h DomainsCtrl) GetRecode()

GetRecode ...

func (DomainsCtrl) GetRecodes

func (h DomainsCtrl) GetRecodes()

GetRecodes -> [GET] :/domain/:did/recodes

Ret Code:[200]

[request=json] 获取指定区间的记录数 [request=html] 获取记录列表页面

成功返回值

{
	"code": "OK",
	"domainID": did,
	"domainName": "name",
	"recodes": [
		{
			"id" : xxx,
			"host": "xxxx",
			"type":	type
			"value": "xxxx"
			"ttl": xxx,
			"dynamic": true,
			"key": "xxxx",
		}
	]
}

失败返回值

code: xxx

func (DomainsCtrl) NewDomain

func (h DomainsCtrl) NewDomain()

NewDomain -> [POST] :/domains

Ret Code:[200]

创建一个新的域名

成功返回值

{
	"code": "OK",
	"id": newID,
}

失败返回值

code: xxx

func (DomainsCtrl) NewRecode

func (h DomainsCtrl) NewRecode()

NewRecode -> [POST] :/domain/:did/recodes

Ret Code:[200]

创建一条记录

成功返回值

{
	"code": "OK",
	"id": newID,
	"key": "xxxx"
}

失败返回值

code: xxx

func (DomainsCtrl) UpdateDomain

func (h DomainsCtrl) UpdateDomain()

UpdateDomain -> [PATCH] :/domain/:did

Ret Code:[200]

更新一条记录

成功返回值

{
	"result": "ok"
}

失败返回值

{
	"result": "xxx"
}

func (DomainsCtrl) UpdateRecode

func (h DomainsCtrl) UpdateRecode()

UpdateRecode -> [PATCH] :/recode/:rid

Ret Code:[200]

更新一条记录

成功返回值

{
	"result": "ok"
}

失败返回值

{
	"result": "xxx"
}

type Downloader

type Downloader struct {
	ContrllerBase
}

func (Downloader) Delete

func (d Downloader) Delete()

Delete -> [POST] :/downloads

Ret Code:[200]

[request=json] 开始一个下载任务

成功返回值

{
	"code": "OK",
	"id":	id
}

失败返回值

code: xxx

func (Downloader) GetDownloads

func (d Downloader) GetDownloads()

GetDownloads -> [GET] :/downloads?r=true&offset=10&limit=0

Ret Code:[200]

[request=json] 获取指定区间的记录数 [request=html] 获取下载列表页面

成功返回值

{
	"code": "OK"
	"tasks" : [
		"id": id,
		"name": "name"
		"src": "src",
		"dest": "dest",
		"size":	size,
		"Transferred": Transferred,
		"bytesPerSecond": bytesPerSecond
	]
}

失败返回值

code: xxx

func (Downloader) StartDownloads

func (d Downloader) StartDownloads()

StartDownloads -> [POST] :/downloads?r=true&offset=10&limit=0

Ret Code:[200]

[request=json] 开始一个下载任务

成功返回值

{
	"code": "OK",
	"id":	id
}

失败返回值

code: xxx

type JsonMap

type JsonMap map[string]interface{}

type SectionItem

type SectionItem struct {
	Name string
	Href string
}

type SectionItems

type SectionItems []*SectionItem

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL