refactor: improve RunPod client

- Refactor RunPod client to use generics for requests and
responses.
- This improves code readability and maintainability.
- Remove redundant code for building GraphQL queries and
handling HTTP requests.
- Add support for environment variables in pod creation.
- Update example with new API key and environment variables.

Co-authored-by: supermario <mariobassem12@gmail.com>
This commit is contained in:
Mahmoud Emad
2025-01-20 15:01:27 +02:00
parent 0d2307acc8
commit d54a1e5a34
5 changed files with 180 additions and 120 deletions

View File

@@ -9,6 +9,7 @@ pub fn (mut h HTTPConnection) get_json_generic[T](req Request) !T {
pub fn (mut h HTTPConnection) post_json_generic[T](req Request) !T {
data := h.post_json_str(req)!
println('data: ${data}')
return json.decode(T, data) or { return error("couldn't decode json for ${req} for ${data}") }
}