Split ingress keys into text/image protocols with Replicate model listing.
CI / docker (push) Successful in 3m38s

Add model input defaults (including prompt), workflow model editing, ingress API docs, and fix img2img image upload filenames for signed URLs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
renjue
2026-06-29 21:41:06 +08:00
parent 2665ac1dee
commit 321683f863
35 changed files with 1646 additions and 167 deletions
+38
View File
@@ -159,6 +159,44 @@ type IngressKeyResolver interface {
ResolveIngressKey(key string) (*model.IngressKey, error)
}
// RequireIngressProtocol restricts routes to ingress keys of the given protocol family.
func RequireIngressProtocol(want model.IngressKeyProtocol) gin.HandlerFunc {
return func(ctx *gin.Context) {
v, ok := ctx.Get("ingress_key")
if !ok {
ctx.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "missing api key"})
return
}
k, ok := v.(*model.IngressKey)
if !ok {
ctx.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "invalid api key"})
return
}
if k.EffectiveProtocol() != want {
abortWrongProtocol(ctx, want, protocolMismatchMessage(k.EffectiveProtocol(), want))
return
}
ctx.Next()
}
}
func protocolMismatchMessage(got, want model.IngressKeyProtocol) string {
if want == model.IngressProtocolImage {
return "this api key is for text (OpenAI) API only; use an image (Replicate) ingress key"
}
return "this api key is for image (Replicate) API only; use a text (OpenAI) ingress key"
}
func abortWrongProtocol(ctx *gin.Context, want model.IngressKeyProtocol, msg string) {
if want == model.IngressProtocolImage {
ctx.AbortWithStatusJSON(http.StatusForbidden, gin.H{"detail": msg})
return
}
ctx.AbortWithStatusJSON(http.StatusForbidden, gin.H{
"error": gin.H{"message": msg, "type": "forbidden"},
})
}
func Logger() gin.HandlerFunc {
return gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string {
return param.TimeStamp.Format(time.RFC3339) + " " + param.Method + " " + param.Path + " " + param.ClientIP + "\n"