示例#1
0
文件: ctrl.go 项目: zaolab/sunnified
func (this *ControllerHandler) ServeContextOptions(ctxt *web.Context, origin map[string]string) {
	router.SetHeaderOrigin(ctxt.Response, ctxt.Request, origin)
	header := ctxt.Response.Header()
	ctrlmgr := this.GetControlManager(ctxt)
	mlist := ctrlmgr.AvailableMethodsList()
	var allow string = "HEAD, OPTIONS"
	mliststr := strings.Join(mlist, ", ")
	if mliststr != "" {
		allow += ", " + mliststr
	}
	header.Set("Allow", allow)
	header.Set("Access-Control-Allow-Methods", mliststr)
	ctxt.Response.WriteHeader(200)
}
示例#2
0
func (this *DynamicHandler) ServeContextOptions(context *web.Context, origin map[string]string) {
	router.SetHeaderOrigin(context.Response, context.Request, origin)

	var (
		header  http.Header                = context.Response.Header()
		ctrlmgr *controller.ControlManager = this.GetControlManager(context)
		mlist   []string                   = ctrlmgr.AvailableMethodsList()
	)

	mliststr := strings.Join(mlist, ", ")
	allow := "HEAD, OPTIONS"

	if mliststr != "" {
		allow += ", " + mliststr
	}

	header.Set("Allow", allow)
	header.Set("Access-Control-Allow-Methods", mliststr)
	context.Response.WriteHeader(200)
}