-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from bento-platform/releases/v2.3.0
releases/v2.3.0
- Loading branch information
Showing
9 changed files
with
129 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package middleware | ||
|
||
import ( | ||
assid "api/models/constants/assembly-id" | ||
"net/http" | ||
|
||
"github.com/labstack/echo" | ||
) | ||
|
||
/* | ||
Echo middleware to ensure a valid `assemblyId` HTTP query parameter was provided | ||
*/ | ||
func MandateAssemblyIdAttribute(next echo.HandlerFunc) echo.HandlerFunc { | ||
return func(c echo.Context) error { | ||
// check for assemblyId query parameter | ||
assemblyId := c.QueryParam("assemblyId") | ||
if len(assemblyId) == 0 || !assid.IsKnownAssemblyId(assemblyId) { | ||
// if no id was provided, or it was invalid, return an error | ||
return echo.NewHTTPError(http.StatusBadRequest, "Missing or unknown assemblyId!") | ||
} | ||
|
||
return next(c) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package assemblyId | ||
|
||
import ( | ||
"api/models/constants" | ||
"strings" | ||
) | ||
|
||
const ( | ||
Unknown constants.AssemblyId = "Unknown" | ||
|
||
GRCh38 constants.AssemblyId = "GRCh38" | ||
GRCh37 constants.AssemblyId = "GRCh37" | ||
NCBI36 constants.AssemblyId = "NCBI36" | ||
Other constants.AssemblyId = "Other" | ||
) | ||
|
||
func CastToAssemblyId(text string) constants.AssemblyId { | ||
switch strings.ToLower(text) { | ||
case "grch38": | ||
return GRCh38 | ||
case "grch37": | ||
return GRCh37 | ||
case "ncbi36": | ||
return NCBI36 | ||
case "other": | ||
return Other | ||
default: | ||
return Unknown | ||
} | ||
} | ||
|
||
func IsKnownAssemblyId(text string) bool { | ||
// attempt to cast to assemblyId and | ||
// return if unknown assemblyId | ||
return CastToAssemblyId(text) != Unknown | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters