Skip to content

Commit

Permalink
simplify api server request template by using Dynamic maps
Browse files Browse the repository at this point in the history
  • Loading branch information
jjuliano committed Sep 17, 2024
1 parent a974f74 commit c62f4c2
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 52 deletions.
22 changes: 3 additions & 19 deletions deps/pkl/APIServerRequest.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,6 @@ module org.kdeps.pkl.APIServerRequest

import "package://pkg.pkl-lang.org/pkl-go/[email protected]#/go.pkl"

class APIServerRequestParams {
name: String
value: String
}

class APIServerRequestData {
name: String
type: String
value: Any
}

class APIServerRequestHeader {
name: String
value: Any
}

hidden apiMethodRegex = Regex(#"^(?i:(GET|POST|PUT|PATCH|DELETE|HEAD))"#)
hidden isValidHTTPMethod = (str) ->
if (str.matches(apiMethodRegex))
Expand All @@ -28,7 +12,7 @@ hidden isValidHTTPMethod = (str) ->
throw("Error: Invalid HTTP method. The provided HTTP method is not supported. Please use one of the following methods: GET, POST, PUT, PATCH, DELETE, or HEAD.")

url: Uri
data: Listing<APIServerRequestData>?
method: String(isValidHTTPMethod)
params: Listing<APIServerRequestParams>?
headers: Listing<APIServerRequestHeader>?
data: String?
params: Mapping<String, String>?
headers: Mapping<String, String>?
8 changes: 4 additions & 4 deletions gen/api_server_request/APIServerRequest.pkl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions gen/api_server_request/APIServerRequestData.pkl.go

This file was deleted.

8 changes: 0 additions & 8 deletions gen/api_server_request/APIServerRequestHeader.pkl.go

This file was deleted.

8 changes: 0 additions & 8 deletions gen/api_server_request/APIServerRequestParams.pkl.go

This file was deleted.

3 changes: 0 additions & 3 deletions gen/api_server_request/init.pkl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c62f4c2

Please sign in to comment.