You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeGetPayReqQueryParamsstruct {
LNURLstring
}
typeGetPayReqRequest= builtin.HttpRequest[ftl.Unit, ftl.Unit, GetPayReqQueryParams]
//ftl:typealiastypeDecimal= decimal.DecimaltypePayReqstruct {
Callbackstring`json:"callback"`// The URL from LN SERVICE which will accept the pay request parametersMaxSendableDecimal`json:"maxSendable"`// Max millisatoshi amount LN SERVICE is willing to receiveMinSendableDecimal`json:"minSendable"`// Min millisatoshi amount LN SERVICE is willing to receive. can not be less than 1 or more than `maxSendable`Metadatastring`json:"metadata"`// Metadata json which must be presented as raw string per LUD06Tagstring`json:"tag"`// Type of LNURL
}
typeLnServiceErrorstruct {
Statusstring`json:"status"`Reasonstring`json:"reason"`
}
typeGetPayReqResponse= builtin.HttpResponse[PayReq, LnServiceError]
//ftl:ingress GET /lnurl/payreqfuncGetPayReq(ctx context.Context, reqGetPayReqRequest) (GetPayReqResponse, error) {
logger:=ftl.LoggerFromContext(ctx)
logger.Infof("lnurl %s", req.Query.LNURL)
returnGetPayReqResponse{
Status: http.StatusNotImplemented,
Error: ftl.Some(LnServiceError{Status: "NotImplemented", Reason: "Not implemented"}),
}, nil
}
sending a request without the required query param results in the following response:
❯ curl -v "http://localhost:8891/lnurl/payreq"
* Host localhost:8891 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
* Trying [::1]:8891...
* connect to ::1 port 8891 from ::1 port 53779 failed: Connection refused
* Trying 127.0.0.1:8891...
* Connected to localhost (127.0.0.1) port 8891
> GET /lnurl/payreq HTTP/1.1
> Host: localhost:8891
> User-Agent: curl/8.7.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 400 Bad Request
< Content-Type: text/plain; charset=utf-8
< Vary: Origin
< X-Content-Type-Options: nosniff
< Date: Wed, 11 Sep 2024 06:23:42 GMT
< Content-Length: 47
<
lnurl.GetPayReqRequest.query.lnurl is required
* Connection #0 to host localhost left intact
it's awesome that FTL handles validation but i think the response can be improved. Most of the current response is unhelpful and potentially misleading to a caller. If i hadn't implemented this verb and received lnurl.GetPayReqRequest.query.lnurl as a response. i would think:
what is lnurl.GetPayReqRequest?
is this the expected shape of some json object i'm supposed to send as a request body?
maybe something along the lines of "lnurl is a required query param"
The text was updated successfully, but these errors were encountered:
Given the following verb:
sending a request without the required query param results in the following response:
it's awesome that FTL handles validation but i think the response can be improved. Most of the current response is unhelpful and potentially misleading to a caller. If i hadn't implemented this verb and received
lnurl.GetPayReqRequest.query.lnurl
as a response. i would think:lnurl.GetPayReqRequest
?maybe something along the lines of "lnurl is a required query param"
The text was updated successfully, but these errors were encountered: