2 releases

0.1.1 Sep 6, 2024
0.1.0 Sep 3, 2024

#167 in HTTP server

Download history 161/week @ 2024-08-30 158/week @ 2024-09-06

319 downloads per month
Used in 2 crates

MIT license

360KB
9K SLoC

htsget-axum

MIT licensed Build Status

Framework dependent code for a local instance of htsget-rs, using Axum.

Overview

This crate is used for running a server instance of htsget-rs. It is based on:

  • Axum for endpoints, routes, and middleware.
  • htsget-http for htsget-rs specific HTTP responses

Usage

For running htsget-rs as an application

This crate uses htsget-config for configuration. See htsget-config for details on how to configure this crate.

To run an instance of this crate, execute the following command:

cargo run -p htsget-axum

Using the default configuration, this will start a ticket server on 127.0.0.1:8080 and a data block server on 127.0.0.1:8081 with data accessible from the data directory. This application supports storage backends defined in htsget-storage.

To use S3Storage, compile with the s3-storage feature:

cargo run -p htsget-axum --features s3-storage

This will start a ticket server with S3Storage using a bucket called "data".

To use UrlStorage, compile with the url-storage feature.

See htsget-search for details on how to structure files.

Using TLS

There two server instances that are launched when running this crate. The ticket server, which returns a list of ticket URLs that a client must fetch. And the data block server, which responds to the URLs in the tickets. By default, the data block server runs without TLS. To run the data block server with TLS, pem formatted X.509 certificates are required.

For development and testing purposes, self-signed certificates can be used. For example, to generate self-signed certificates run:

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365 -nodes -subj '/CN=localhost'

It is not recommended to use self-signed certificates in a production environment as this is considered insecure.

Example requests

Using default configuration settings, this crate responds to queries referencing files in the data directory. Some example requests using curl are shown below:

  • GET
curl '127.0.0.1:8080/variants/data/vcf/sample1-bcbio-cancer'
  • POST
curl --header "Content-Type: application/json" -d '{}' '127.0.0.1:8080/variants/data/vcf/sample1-bcbio-cancer'
  • Parametrised GET
curl '127.0.0.1:8080/variants/data/vcf/sample1-bcbio-cancer?format=VCF&class=header'
  • Parametrised POST
curl --header "Content-Type: application/json" -d '{"format": "VCF", "regions": [{"referenceName": "chrM"}]}' '127.0.0.1:8080/variants/data/vcf/sample1-bcbio-cancer'
  • Service info
curl '127.0.0.1:8080/variants/service-info'

As a library

This crates has some components which may be useful to other crates. Namely, in contains Axum routing functions for htsget-rs. It also contains the data block server which fetches data from a LocalStorage storage backend using htsget-storage.

Feature flags

This crate has the following features:

  • s3-storage: used to enable S3Storage functionality.
  • url-storage: used to enable UrlStorage functionality.

License

This project is licensed under the MIT license.

Dependencies

~35–53MB
~1M SLoC