package api

import (
	"errors"

	"github.com/labstack/echo"
)

// GetProjectID returns projectID for current HTTP request
func GetProjectID(c echo.Context) int64 {
	if projectID, ok := c.Get("projectID").(int64); ok {
		return projectID
	}
	panic(errors.New("failed to get projectID, is mw.RequireProject call missing?"))
}

package api

import "github.com/labstack/echo"

// GetProjectID returns projectID for current HTTP request
func GetProjectID(c echo.Context) int64 {
	return c.Get("projectID").(int64)
}

--- 
+++ 
@@ -1,8 +1,15 @@
 package api
 
-import "github.com/labstack/echo"
+import (
+	"errors"
+
+	"github.com/labstack/echo"
+)
 
 // GetProjectID returns projectID for current HTTP request
 func GetProjectID(c echo.Context) int64 {
-	return c.Get("projectID").(int64)
+	if projectID, ok := c.Get("projectID").(int64); ok {
+		return projectID
+	}
+	panic(errors.New("failed to get projectID, is mw.RequireProject call missing?"))
 }
Use safe type assertion in GetProjectID
