Ejemplo n.º 1
0
func (h *Handler) ServeHTTP(conn http.ResponseWriter, req *http.Request) {
	blobRef := blobFromUrlPath(req.URL.Path)
	if blobRef == nil {
		http.Error(conn, "Malformed GET URL.", 400)
		return
	}

	switch {
	case h.AllowGlobalAccess || auth.IsAuthorized(req):
		serveBlobRef(conn, req, blobRef, h.Fetcher)
	case auth.TriedAuthorization(req):
		log.Printf("Attempted authorization failed on %s", req.URL)
		auth.SendUnauthorized(conn)
	default:
		handleGetViaSharing(conn, req, blobRef, h.Fetcher)
	}
}
Ejemplo n.º 2
0
func (rh *RootHandler) ServeHTTP(conn http.ResponseWriter, req *http.Request) {
	if rh.ui != nil && camliMode(req) == "config" && auth.IsAuthorized(req) {
		rh.ui.serveDiscovery(conn, req)
		return
	}

	if rh.Stealth {
		return
	}

	configLink := ""
	if auth.LocalhostAuthorized(req) {
		configLink = "<p>If you're coming from localhost, hit <a href='/setup'>/setup</a>.</p>"
	}
	fmt.Fprintf(conn,
		"<html><body>This is camlistored, a "+
			"<a href='http://camlistore.org'>Camlistore</a> server."+
			"%s</body></html>\n", configLink)
}
Ejemplo n.º 3
0
func (rh *RootHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
	if wantsDiscovery(req) {
		if auth.IsAuthorized(req) {
			rh.serveDiscovery(rw, req)
			return
		}
		if !rh.Stealth {
			http.Error(rw, "Unauthorized", http.StatusUnauthorized)
		}
		return
	}

	if rh.Stealth {
		return
	}

	configLink := ""
	if auth.LocalhostAuthorized(req) {
		configLink = "<p>If you're coming from localhost, hit <a href='/setup'>/setup</a>.</p>"
	}
	fmt.Fprintf(rw, "<html><body>This is camlistored, a "+
		"<a href='http://camlistore.org'>Camlistore</a> server."+
		"%s</body></html>\n", configLink)
}