-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from microsoft/feature/base-request
- adds base request builder class
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package abstractions | ||
|
||
// BaseRequestBuilder is the base class for all request builders. | ||
type BaseRequestBuilder struct { | ||
// Path parameters for the request | ||
PathParameters map[string]string | ||
// The request adapter to use to execute the requests. | ||
RequestAdapter RequestAdapter | ||
// Url template to use to build the URL for the current request builder | ||
UrlTemplate string | ||
} | ||
|
||
// NewBaseRequestBuilder creates a new BaseRequestBuilder instance. | ||
func NewBaseRequestBuilder(requestAdapter RequestAdapter, urlTemplate string, pathParameters map[string]string) *BaseRequestBuilder { | ||
if requestAdapter == nil { | ||
panic("requestAdapter cannot be nil") | ||
} | ||
pathParametersCopy := make(map[string]string) | ||
if pathParameters != nil { | ||
for idx, item := range pathParameters { | ||
pathParametersCopy[idx] = item | ||
} | ||
} | ||
return &BaseRequestBuilder{ | ||
RequestAdapter: requestAdapter, | ||
UrlTemplate: urlTemplate, | ||
PathParameters: pathParametersCopy, | ||
} | ||
} |