http method fix
This commit is contained in:
parent
fa92c325dd
commit
9dd77fe0bf
6 changed files with 13 additions and 5 deletions
|
|
@ -580,7 +580,7 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
|
|
||||||
- GetUserOffer
|
- GetUserOffer
|
||||||
- auth type: __User__
|
- auth type: __User__
|
||||||
- http method: __get__
|
- http method: __post__
|
||||||
- http route: __/api/user/offer/get__
|
- http route: __/api/user/offer/get__
|
||||||
- input: [OfferId](#OfferId)
|
- input: [OfferId](#OfferId)
|
||||||
- output: [OfferConfig](#OfferConfig)
|
- output: [OfferConfig](#OfferConfig)
|
||||||
|
|
|
||||||
|
|
@ -1087,7 +1087,14 @@ func NewClient(params ClientParams) *Client {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
finalRoute := "/api/user/offer/get"
|
finalRoute := "/api/user/offer/get"
|
||||||
resBody, err := doGetRequest(params.BaseURL+finalRoute, auth)
|
body, err := json.Marshal(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
result := ResultError{}
|
result := ResultError{}
|
||||||
err = json.Unmarshal(resBody, &result)
|
err = json.Unmarshal(resBody, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -1114,7 +1114,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => {
|
||||||
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback); if (opts.throwErrors) throw e }
|
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger, { ...info, ...stats, ...authCtx }, opts.metricsCallback); if (opts.throwErrors) throw e }
|
||||||
})
|
})
|
||||||
if (!opts.allowNotImplementedMethods && !methods.GetUserOffer) throw new Error('method: GetUserOffer is not implemented')
|
if (!opts.allowNotImplementedMethods && !methods.GetUserOffer) throw new Error('method: GetUserOffer is not implemented')
|
||||||
app.get('/api/user/offer/get', async (req, res) => {
|
app.post('/api/user/offer/get', async (req, res) => {
|
||||||
const info: Types.RequestInfo = { rpcName: 'GetUserOffer', batch: false, nostr: false, batchSize: 0}
|
const info: Types.RequestInfo = { rpcName: 'GetUserOffer', batch: false, nostr: false, batchSize: 0}
|
||||||
const stats: Types.RequestStats = { startMs:req.startTimeMs || 0, start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n }
|
const stats: Types.RequestStats = { startMs:req.startTimeMs || 0, start:req.startTime || 0n, parse: process.hrtime.bigint(), guard: 0n, validate: 0n, handle: 0n }
|
||||||
let authCtx: Types.AuthContext = {}
|
let authCtx: Types.AuthContext = {}
|
||||||
|
|
|
||||||
|
|
@ -512,7 +512,7 @@ export default (params: ClientParams) => ({
|
||||||
const auth = await params.retrieveUserAuth()
|
const auth = await params.retrieveUserAuth()
|
||||||
if (auth === null) throw new Error('retrieveUserAuth() returned null')
|
if (auth === null) throw new Error('retrieveUserAuth() returned null')
|
||||||
let finalRoute = '/api/user/offer/get'
|
let finalRoute = '/api/user/offer/get'
|
||||||
const { data } = await axios.get(params.baseUrl + finalRoute, { headers: { 'authorization': auth } })
|
const { data } = await axios.post(params.baseUrl + finalRoute, request, { headers: { 'authorization': auth } })
|
||||||
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
|
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
|
||||||
if (data.status === 'OK') {
|
if (data.status === 'OK') {
|
||||||
const result = data
|
const result = data
|
||||||
|
|
|
||||||
|
|
@ -440,6 +440,7 @@ export default (params: NostrClientParams, send: (to:string, message: NostrRequ
|
||||||
const auth = await params.retrieveNostrUserAuth()
|
const auth = await params.retrieveNostrUserAuth()
|
||||||
if (auth === null) throw new Error('retrieveNostrUserAuth() returned null')
|
if (auth === null) throw new Error('retrieveNostrUserAuth() returned null')
|
||||||
const nostrRequest: NostrRequest = {}
|
const nostrRequest: NostrRequest = {}
|
||||||
|
nostrRequest.body = request
|
||||||
const data = await send(params.pubDestination, {rpcName:'GetUserOffer',authIdentifier:auth, ...nostrRequest })
|
const data = await send(params.pubDestination, {rpcName:'GetUserOffer',authIdentifier:auth, ...nostrRequest })
|
||||||
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
|
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
|
||||||
if (data.status === 'OK') {
|
if (data.status === 'OK') {
|
||||||
|
|
|
||||||
|
|
@ -477,7 +477,7 @@ service LightningPub {
|
||||||
|
|
||||||
rpc GetUserOffer(structs.OfferId) returns (structs.OfferConfig){
|
rpc GetUserOffer(structs.OfferId) returns (structs.OfferConfig){
|
||||||
option (auth_type) = "User";
|
option (auth_type) = "User";
|
||||||
option (http_method) = "get";
|
option (http_method) = "post";
|
||||||
option (http_route) = "/api/user/offer/get";
|
option (http_route) = "/api/user/offer/get";
|
||||||
option (nostr) = true;
|
option (nostr) = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue