-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
all: cleanup a number of things, including error handling and documen…
…tation (#6) * sips: clean up error handling a bit * internal/log: return an error from `Errorf()` * cmd/sips: use new error handling stuff from `internal/log` and `sips` * all: better documentation
- Loading branch information
1 parent
fce94d4
commit 4148bc6
Showing
10 changed files
with
173 additions
and
85 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,41 @@ | ||
package main | ||
|
||
import "net/http" | ||
|
||
type statusError struct { | ||
StatusCode int | ||
Err error | ||
} | ||
|
||
func Unauthorized(err error) error { | ||
return statusError{ | ||
StatusCode: http.StatusUnauthorized, | ||
Err: err, | ||
} | ||
} | ||
|
||
func NotFound(err error) error { | ||
return statusError{ | ||
StatusCode: http.StatusNotFound, | ||
Err: err, | ||
} | ||
} | ||
|
||
func BadRequest(err error) error { | ||
return statusError{ | ||
StatusCode: http.StatusBadRequest, | ||
Err: err, | ||
} | ||
} | ||
|
||
func (err statusError) Error() string { | ||
return err.Err.Error() | ||
} | ||
|
||
func (err statusError) Unwrap() error { | ||
return err.Err | ||
} | ||
|
||
func (err statusError) Status() int { | ||
return err.StatusCode | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// sips is the primary implementation of a simple pinning service daemon. | ||
package main | ||
|
||
import ( | ||
|
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,3 +1,4 @@ | ||
// sipsctl is a simple utility for administrating the database used by SIPS. | ||
package main | ||
|
||
import ( | ||
|
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
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,8 @@ | ||
// Package sips provides structures for implementing an IPFS pinning service. | ||
// | ||
// The primary purpose of this package is to allow a user to create an | ||
// IPFS pinning service with minimal effort. The package is based | ||
// around the PinHandler interface. An implementation of this | ||
// interface can be passed to the Handler function in order to create | ||
// an HTTP handler that serves a valid pinning service. | ||
package sips |
Oops, something went wrong.