Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( MimeTypeCar = "application/vnd.ipld.car" // The only accepted MIME type MimeTypeCarVersion = "1" // We only accept version 1 of the MIME type FormatParameterCar = "car" // The only valid format parameter value FilenameExtCar = ".car" // The only valid filename extension DefaultIncludeDupes = true // The default value for an unspecified "dups" parameter. See https://github.com/ipfs/specs/pull/412. ResponseAcceptRangesHeader = "none" // We currently don't accept range requests ResponseCacheControlHeader = "public, max-age=29030400, immutable" // Magic cache control values ResponseChunkDelimeter = []byte("0\r\n") // An http/1.1 chunk delimeter, used for specifying an early end to the response ResponseContentTypeHeader = fmt.Sprintf("%s; version=%s", MimeTypeCar, MimeTypeCarVersion) )
Functions ¶
func CheckFormat ¶ added in v0.13.0
CheckFormat validates that the data being requested is of the type CAR. We do this validation because the http gateway path spec allows for additional response formats that Lassie does not currently support, so we throw an error in the cases where the request is requesting one of Lassie's unsupported response formats. Lassie only supports returning CAR data.
The spec outlines that the requesting format can be provided via the Accept header or the format query parameter.
Lassie only allows the application/vnd.ipld.car Accept header https://specs.ipfs.tech/http-gateways/path-gateway/#accept-request-header
Lassie only allows the "car" format query parameter https://specs.ipfs.tech/http-gateways/path-gateway/#format-request-query-parameter
func ParseAccept ¶ added in v0.13.0
ParseAccept validates that the request Accept header is of the type CAR and returns whether or not duplicate blocks are allowed in the response via IPIP-412: https://github.com/ipfs/specs/pull/412.
func ParseFilename ¶ added in v0.13.0
ParseFilename returns the filename query parameter or an error if the filename extension is not ".car". Lassie only supports returning CAR data. See https://specs.ipfs.tech/http-gateways/path-gateway/#filename-request-query-parameter
Types ¶
type HttpServer ¶
type HttpServer struct {
// contains filtered or unexported fields
}
HttpServer is a Lassie server for fetching data from the network via HTTP
func NewHttpServer ¶
func NewHttpServer(ctx context.Context, lassie *lassie.Lassie, cfg HttpServerConfig) (*HttpServer, error)
NewHttpServer creates a new HttpServer
func (HttpServer) Addr ¶
func (s HttpServer) Addr() string
Addr returns the listening address of the server
func (*HttpServer) Close ¶
func (s *HttpServer) Close() error
Close shutsdown the server and cancels the server context
func (*HttpServer) Start ¶
func (s *HttpServer) Start() error
Start starts the http server, returning an error if the server failed to start