mirror of
https://github.com/sablierapp/sablier.git
synced 2025-12-21 21:33:06 +01:00
fix: add http error responses (#494)
This features adds rfc7807 Problem detail responses when an error happens processing a request. This will greatly improve the common issues with "blank pages" and "404 pages" issues which should now properly tell the user what input was wrong (group that does not exist, container name that does not exist, etc.)
This commit is contained in:
18
internal/api/api_response_headers.go
Normal file
18
internal/api/api_response_headers.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/sablierapp/sablier/app/sessions"
|
||||
)
|
||||
|
||||
const SablierStatusHeader = "X-Sablier-Session-Status"
|
||||
const SablierStatusReady = "ready"
|
||||
const SablierStatusNotReady = "not-ready"
|
||||
|
||||
func AddSablierHeader(c *gin.Context, session *sessions.SessionState) {
|
||||
if session.IsReady() {
|
||||
c.Header(SablierStatusHeader, SablierStatusReady)
|
||||
} else {
|
||||
c.Header(SablierStatusHeader, SablierStatusNotReady)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user