xgo

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Copyright [2018] [jc3wish]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright [2018] [jc3wish]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRoute

func AddRoute(route string, callbackFUns func(http.ResponseWriter, *http.Request)) error

func AddStaticRoute

func AddStaticRoute(route string, dir string)

func SetFirstCallBack

func SetFirstCallBack(callbackFUns func(http.ResponseWriter, *http.Request) bool)

func Start

func Start(IpAndPort string) error

func StartTLS

func StartTLS(IpAndPort string, serverKey string, serverCrt string) error

Types

type FirstCallBackFun

type FirstCallBackFun func(http.ResponseWriter, *http.Request) bool
var FirstCallBack FirstCallBackFun

type HandlerFun

type HandlerFun interface {
	Callback(http.ResponseWriter, *http.Request)
}

type HandlerFunc

type HandlerFunc func(http.ResponseWriter, *http.Request)

func (HandlerFunc) Callback

func (f HandlerFunc) Callback(w http.ResponseWriter, r *http.Request)

type Session

type Session struct {
	// contains filtered or unexported fields
}

—————————————————————————— 会话

type SessionMgr

type SessionMgr struct {
	// contains filtered or unexported fields
}

Session会话管理

func NewSessionMgr

func NewSessionMgr(cookieName string, maxLifeTime int64) *SessionMgr

创建会话管理器(cookieName:在浏览器中cookie的名字;maxLifeTime:最长生命周期)

func (*SessionMgr) CheckCookieValid

func (mgr *SessionMgr) CheckCookieValid(w http.ResponseWriter, r *http.Request) string

判断Cookie的合法性(每进入一个页面都需要判断合法性)

func (*SessionMgr) EndSession

func (mgr *SessionMgr) EndSession(w http.ResponseWriter, r *http.Request)

结束Session

func (*SessionMgr) EndSessionBy

func (mgr *SessionMgr) EndSessionBy(sessionID string)

结束session

func (*SessionMgr) GC

func (mgr *SessionMgr) GC()

GC回收

func (*SessionMgr) GetLastAccessTime

func (mgr *SessionMgr) GetLastAccessTime(sessionID string) time.Time

更新最后访问时间

func (*SessionMgr) GetSessionIDList

func (mgr *SessionMgr) GetSessionIDList() []string

得到sessionID列表

func (*SessionMgr) GetSessionVal

func (mgr *SessionMgr) GetSessionVal(sessionID string, key interface{}) (interface{}, bool)

得到session里面的值

func (*SessionMgr) NewSessionID

func (mgr *SessionMgr) NewSessionID() string

创建唯一ID

func (*SessionMgr) SetSessionVal

func (mgr *SessionMgr) SetSessionVal(sessionID string, key interface{}, value interface{})

设置session里面的值

func (*SessionMgr) StartSession

func (mgr *SessionMgr) StartSession(w http.ResponseWriter, r *http.Request) string

在开始页面登陆页面,开始Session

Jump to

Keyboard shortcuts

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