cors

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2015 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package cors is for cors * * Author: CZ cz.theng@gmail.com

* CORS allow remote domain to access resources. Before this ,you should create a CORS rule for the bucket.

cors.Create

Create(bucketName, location string, corsInfo []CORSRuleInfo) (ossapiError *ossapi.Error) Create CORS attribute for bucket.OSCR info is descriped by CORSRuleInfo.

type CORSRuleInfo struct {
    AllowedOrigin []string
    AllowedMethod []string
    AllowedHeader []string
    ExposeHeader  []string
    MaxAgeSeconds uint64
}

AllowedOrigin: origin vister source . AllowedMethod: Valied Http Method AllowedHeader: Valied Http Header ExposeHeader : Valied header from client MaxAgeSeconds: Cache time Info is a Rule list. With AllowedOrigin AllowedMethod AllowedHeader ExposeHeader MaxAgeSeconds

cors.Query

Query(bucketName, location string) (rstInfo []CORSRuleInfo, ossapiError *ossapi.Error) Query CORS information of bucket. CORS is store in CORSRuleInfo which descript above.

Info is a Rule list. With AllowedOrigin AllowedMethod AllowedHeader ExposeHeader MaxAgeSeconds

cors.Delete

Delete(bucketName, location string) (ossapiError *ossapi.Error) Delete CORS infomation of bucket.After this, other domain can't vister this bucket.

Info is a Rule list. With AllowedOrigin AllowedMethod AllowedHeader ExposeHeader MaxAgeSeconds

cors.Option

Option(objName, bucketName, location string, optionInfo *OptionReqInfo) (rstInfo *OptionRspInfo, ossapiError *ossapi.Error) Query Bucket's CORS information to decide weather visitable. vister should set OptionReqInfo:

type OptionReqInfo struct {
    Origin  string
    Method  string
    Headers string
}

CORS information is stored in OptionRspInfo:

type OptionRspInfo struct {
    AllowOrigin   string
    AllowMethods  string
    AllowHeaders  string
    ExposeHeaders string
    MaxAge        uint64
}

Info is a Rule list. With AllowedOrigin AllowedMethod AllowedHeader ExposeHeader MaxAgeSeconds

*

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(bucketName, location string, corsInfo []RuleInfo) (ossapiError *ossapi.Error)

Create Create a CORS rule @param bucketName : name of bucket @param location : bucket's loction @param corsInfo : cors rules @return ossapiError : nil on success

func Delete

func Delete(bucketName, location string) (ossapiError *ossapi.Error)

Delete bucket's cors attribute @param bucketName: name of bucket @param location : location of bucket @return ossapiError : nil on success

Types

type Info added in v1.0.1

type Info struct {
	XMLName  xml.Name `xml:"CORSConfiguration"`
	CORSRule []RuleInfo
}

Info is XML wraper

type OptionReqInfo

type OptionReqInfo struct {
	Origin  string
	Method  string
	Headers string
}

OptionReqInfo is Reqinfo

type OptionRspInfo

type OptionRspInfo struct {
	AllowOrigin   string
	AllowMethods  string
	AllowHeaders  string
	ExposeHeaders string
	MaxAge        uint64
}

OptionRspInfo is Resoponse info

func Option

func Option(objName, bucketName, location string, optionInfo *OptionReqInfo) (rstInfo *OptionRspInfo, ossapiError *ossapi.Error)

Option Query CORS permission of bucket @param objName : object to access @param bucketName: bucket to access @param location: bucket's location @param optionInfo : CORS requet @return rstInfo: CORS permisson @return ossapiError : nil on success

type RuleInfo added in v1.0.1

type RuleInfo struct {
	AllowedOrigin []string
	AllowedMethod []string
	AllowedHeader []string
	ExposeHeader  []string
	MaxAgeSeconds uint64
}

RuleInfo is CORS rules

func Query

func Query(bucketName, location string) (rstInfo []RuleInfo, ossapiError *ossapi.Error)

Query bucket's cors info @param bucketName : name of bucket @param location: location of buket @return rstinfo : CORS rules @rreturn ossapiError : nil on success

Jump to

Keyboard shortcuts

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