Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
add endpoint for c4gh header size
Browse files Browse the repository at this point in the history
Co-authored-by: Kostas Koumpouras <[email protected]>
Co-authored-by: Panos Chatzopoulos <[email protected]>"
  • Loading branch information
pahatz and kostas-kou committed Nov 1, 2023
1 parent e49dac6 commit 6883b26
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func Setup() *http.Server {
router.GET("/s3-encrypted/*path", SelectedMiddleware(), s3.Download)
router.GET("/health", healthResponse)
router.GET("/header/*path", SelectedMiddleware(), s3.Download)
router.GET("/c4gheadsize/*path", SelectedMiddleware(), s3.Download)

// Configure TLS settings
log.Info("(3/5) Configuring TLS")
Expand Down
2 changes: 2 additions & 0 deletions api/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ func GetObject(c *gin.Context) {
c.Params = append(c.Params, gin.Param{Key: "fileid", Value: fileInfo.FileID})
if strings.Contains(c.Request.URL.String(), "header") {
c.Params = append(c.Params, gin.Param{Key: "type", Value: "header"})
} else if strings.Contains(c.Request.URL.String(), "c4gheadsize") {
c.Params = append(c.Params, gin.Param{Key: "type", Value: "headersize"})
}

// Download the file
Expand Down
15 changes: 15 additions & 0 deletions api/sda/sda.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func Download(c *gin.Context) {
return
}
}
log.Debug("- - - - - - - test 1 - - - - - - - ")
if c.Param("type") == "header" {
bamReader, err := bam.NewReader(fileStream, 0)
if err != nil {
Expand All @@ -237,7 +238,21 @@ func Download(c *gin.Context) {

return

} else if c.Param("type") == "headersize" {
log.Debug("- - - - - - - test 2 - - - - - - - ")
head := fileDetails.Header
log.Debug("head: ", head)
//headlength := len(head)

Check failure on line 245 in api/sda/sda.go

View workflow job for this annotation

GitHub Actions / Check code (1.20)

commentFormatting: put a space between `//` and comment text (gocritic)
headlength := bytes.NewReader(head)
log.Debug("headlength size: ", headlength.Size())
buf := new(bytes.Buffer)
len := strconv.Itoa(int(headlength.Size()))
fmt.Fprint(buf, len)
sendStream(c.Writer, buf)

return
}
log.Debug("- - - - - - - test 3 - - - - - - - ")
sendStream(c.Writer, fileStream)
}

Expand Down

0 comments on commit 6883b26

Please sign in to comment.