Ejemplo n.º 1
0
//new set content-type to text and  returns serverCGI obj.
func new(w http.ResponseWriter, r *http.Request) (*serverCGI, error) {
	c, err := cgi.NewCGI(w, r)
	if err != nil {
		return nil, err
	}
	a := serverCGI{
		CGI: c,
	}

	if w != nil {
		w.Header().Set("Content-Type", "text/plain")
	}

	return &a, nil
}
Ejemplo n.º 2
0
//new returns threadCGI obj.
func new(w http.ResponseWriter, r *http.Request) (*threadCGI, error) {
	c, err := cgi.NewCGI(w, r)
	if err != nil {
		c.Print403()
		return nil, err
	}
	if !c.CheckVisitor() {
		c.Print403()
		return nil, errors.New("visitor now allowed")
	}
	t := threadCGI{
		CGI: c,
	}

	t.IsThread = true
	return &t, nil
}
Ejemplo n.º 3
0
//new returns mchCGI obj if visitor  is allowed.
//if not allowed print 403.
func new(w http.ResponseWriter, r *http.Request) (*mchCGI, error) {
	c, err := cgi.NewCGI(w, r)
	if err != nil {
		w.WriteHeader(403)
		fmt.Fprintf(w, "403 Forbidden")
		return nil, err
	}
	a := mchCGI{
		CGI: c,
	}
	if !c.CheckVisitor() {
		http.Error(w, "403 Forbidden", http.StatusForbidden)
		return nil, errors.New("403 forbidden")
	}

	return &a, nil
}
Ejemplo n.º 4
0
//new returns gatewayCGI obj with filter.tag value in form.
func new(w http.ResponseWriter, r *http.Request) (*gatewayCGI, error) {
	c, err := cgi.NewCGI(w, r)
	if err != nil {
		return nil, err
	}
	a := gatewayCGI{
		CGI: c,
	}

	filter := r.FormValue("filter")
	tag := r.FormValue("tag")

	if filter != "" {
		a.Filter = strings.ToLower(filter)
	} else {
		a.Tag = strings.ToLower(tag)
	}

	if !a.CheckVisitor() {
		a.Print403()
		return nil, errors.New("permission denied")
	}
	return &a, nil
}