Hello Julia Community!!!
Can’t tell you how much I’m enjoying Julia’s core concepts and implementation. I’m hoping this becomes my main language.
Ok, so I created a little prototype using JuliaWebAPI and its GitHub documentation. My goals are simple: call listSoundFiles via the API and get json back what’s in SoundFile struct (succesful) and then be able to update it (failed).
This works and I get json:
curl http://localhost:8888/listSoundFiles
However, this doesn’t:
curl -d “title1=Concerto&author=Beethoven?date1=01102020?tag1=classical?url1=https://duckduckgo.com” http://localhost:8888/updateSoundFiles
I get this error:
{“data”:“ErrorException("function updateSoundFiles does not accept keyword arguments")”,“code”:-2}
As I said, I’m new to Julia so I’m assuming my issue is with the syntax for updateSoundFiles or perhaps a scope issue? Maybe the JuliaWebAPI.create_responder needs different options for POST calls? Regardless, I haven’t been able to figure it out.
Any help would really be appreciated.
Thanks,
Jose
srvr.jl
using Dates
using JuliaWebAPI
mutable struct SoundFile
title::String
creator::String
date::String
tags::Array
URL::String
end
const InfoncastSoundFiles = SoundFile[
SoundFile("Fur Elise", "Ludwig Beethoven","12202019",["mp3","song", "music"],"”https://URL Here”"),
SoundFile("Fidelio", "Ludwig Beethoven","11032011",["song", "dance"],"”https://URL Here”),
SoundFile("Missa Solemnis", "Ludwig Beethoven","03102019",["mp3", "song"], ”https://URL Here”)
]
function listSoundFiles()
return InfoncastSoundFiles
end
function updateSoundFiles(title1, author, date1, tag1, url1)
SoundFile(title,creator,date,tags,url)
end
process(
JuliaWebAPI.create_responder([
(listSoundFiles, true),
(updateSoundFiles, true)
], "tcp://127.0.0.1:9999", true, "")
)