Home Download Docs Code Community
     1	/*
     2	Copyright 2014 The Perkeep Authors
     3	
     4	Licensed under the Apache License, Version 2.0 (the "License");
     5	you may not use this file except in compliance with the License.
     6	You may obtain a copy of the License at
     7	
     8	     http://www.apache.org/licenses/LICENSE-2.0
     9	
    10	Unless required by applicable law or agreed to in writing, software
    11	distributed under the License is distributed on an "AS IS" BASIS,
    12	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13	See the License for the specific language governing permissions and
    14	limitations under the License.
    15	*/
    16	
    17	// Package protocol contains types for Perkeep protocol types.
    18	package protocol // import "perkeep.org/pkg/blobserver/protocol"
    19	
    20	import (
    21		"encoding/json"
    22	
    23		"perkeep.org/pkg/blob"
    24	)
    25	
    26	// StatResponse is the JSON document returned from the blob batch stat
    27	// handler.
    28	//
    29	// See doc/protocol/blob-stat-protocol.txt.
    30	type StatResponse struct {
    31		Stat        []blob.SizedRef `json:"stat"`
    32		CanLongPoll bool            `json:"canLongPoll"` // TODO: move this to discovery?
    33	}
    34	
    35	func (p *StatResponse) MarshalJSON() ([]byte, error) {
    36		v := *p
    37		if v.Stat == nil {
    38			v.Stat = []blob.SizedRef{}
    39		}
    40		return json.Marshal(v)
    41	}
    42	
    43	// UploadResponse is the JSON document returned from the blob batch
    44	// upload handler.
    45	//
    46	// See doc/protocol/blob-upload-protocol.txt.
    47	type UploadResponse struct {
    48		Received  []blob.SizedRef `json:"received"`
    49		ErrorText string          `json:"errorText,omitempty"`
    50	}
    51	
    52	func (p *UploadResponse) MarshalJSON() ([]byte, error) {
    53		v := *p
    54		if v.Received == nil {
    55			v.Received = []blob.SizedRef{}
    56		}
    57		return json.Marshal(v)
    58	}
Website layout inspired by memcached.
Content by the authors.