-
Notifications
You must be signed in to change notification settings - Fork 55
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 #48 from elimity-com/feature/47-errors-package
errors package
- Loading branch information
Showing
15 changed files
with
250 additions
and
202 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,49 @@ | ||
package errors | ||
|
||
// GetError represents an error that is returned by a GET HTTP request. | ||
type GetError int | ||
|
||
const ( | ||
// GetErrorNil indicates that no error occurred during handling a GET HTTP request. | ||
GetErrorNil GetError = iota | ||
// GetErrorResourceNotFound returns an error with status code 404 and a human readable message containing the identifier | ||
// of the resource that was requested but not found. | ||
GetErrorResourceNotFound | ||
) | ||
|
||
// PostError represents an error that is returned by a POST HTTP request. | ||
type PostError int | ||
|
||
const ( | ||
// PostErrorNil indicates that no error occurred during handling a POST HTTP request. | ||
PostErrorNil PostError = iota | ||
// PostErrorUniqueness shall be returned when one or more of the attribute values are already in use or are reserved. | ||
PostErrorUniqueness | ||
) | ||
|
||
// PutError represents an error that is returned by a PUT HTTP request. | ||
type PutError int | ||
|
||
const ( | ||
// PutErrorNil indicates that no error occurred during handling a PUT HTTP request. | ||
PutErrorNil PutError = iota | ||
// PutErrorUniqueness shall be returned when one or more of the attribute values are already in use or are reserved. | ||
PutErrorUniqueness | ||
// PutErrorMutability shall be returned when the attempted modification is not compatible with the target | ||
// attribute's mutability or current state. | ||
PutErrorMutability | ||
// PutErrorResourceNotFound returns an error with status code 404 and a human readable message containing the identifier | ||
// of the resource that was requested to be replaced but not found. | ||
PutErrorResourceNotFound | ||
) | ||
|
||
// DeleteError represents an error that is returned by a DELETE HTTP request. | ||
type DeleteError int | ||
|
||
const ( | ||
// DeleteErrorNil indicates that no error occurred during handling a DELETE HTTP request. | ||
DeleteErrorNil DeleteError = iota | ||
// DeleteErrorResourceNotFound returns an error with status code 404 and a human readable message containing the identifier | ||
// of the resource that was requested to be deleted but not found. | ||
DeleteErrorResourceNotFound | ||
) |
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 |
---|---|---|
@@ -1,27 +1,34 @@ | ||
package scim | ||
|
||
import ( | ||
"io/ioutil" | ||
"log" | ||
"net/http" | ||
) | ||
|
||
// Errors are ignored to keep it simple. | ||
func ExampleNewServer() { | ||
config, _ := NewServiceProviderConfigFromFile("/path/to/config") | ||
schema, _ := NewSchemaFromFile("/path/to/schema") | ||
resourceType, _ := NewResourceTypeFromFile("/path/to/resourceType", nil) | ||
server, _ := NewServer(config, []Schema{schema}, []ResourceType{resourceType}) | ||
rawConfig, _ := ioutil.ReadFile("/path/to/config") | ||
config, _ := NewServiceProviderConfig(rawConfig) | ||
rawSchema, _ := ioutil.ReadFile("/path/to/schema") | ||
schema, _ := NewSchema(rawSchema) | ||
rawResourceType, _ := ioutil.ReadFile("/path/to/resourceType") | ||
resourceType, _ := NewResourceType(rawResourceType, nil) | ||
|
||
server, _ := NewServer(config, []Schema{schema}, []ResourceType{resourceType}) | ||
log.Fatal(http.ListenAndServe(":8080", server)) | ||
} | ||
|
||
// Errors are ignored to keep it simple. | ||
func ExampleNewServer_basePath() { | ||
config, _ := NewServiceProviderConfigFromFile("/path/to/config") | ||
schema, _ := NewSchemaFromFile("/path/to/schema") | ||
resourceType, _ := NewResourceTypeFromFile("/path/to/resourceType", nil) | ||
server, _ := NewServer(config, []Schema{schema}, []ResourceType{resourceType}) | ||
rawConfig, _ := ioutil.ReadFile("/path/to/config") | ||
config, _ := NewServiceProviderConfig(rawConfig) | ||
rawSchema, _ := ioutil.ReadFile("/path/to/schema") | ||
schema, _ := NewSchema(rawSchema) | ||
rawResourceType, _ := ioutil.ReadFile("/path/to/resourceType") | ||
resourceType, _ := NewResourceType(rawResourceType, nil) | ||
|
||
server, _ := NewServer(config, []Schema{schema}, []ResourceType{resourceType}) | ||
http.Handle("/scim/", http.StripPrefix("/scim", server)) | ||
log.Fatal(http.ListenAndServe(":8080", nil)) | ||
} |
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
Oops, something went wrong.