mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-06 01:06:26 +08:00
eliminate dead code (#282)
This commit is contained in:
@@ -30,10 +30,6 @@ type errorer interface {
|
||||
error() error
|
||||
}
|
||||
|
||||
type errorWrapper struct {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
func decodeRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
||||
var req checkinRequest
|
||||
err := plist.NewDecoder(io.LimitReader(r.Body, 10000)).Decode(&req)
|
||||
|
||||
@@ -257,7 +257,3 @@ func UnmarshalEvent(data []byte, e *Event) error {
|
||||
func stringPtr(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
func boolPtr(b bool) *bool {
|
||||
return &b
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package command
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
@@ -46,27 +45,6 @@ func EncodeError(ctx context.Context, err error, w http.ResponseWriter) {
|
||||
})
|
||||
}
|
||||
|
||||
func codeFromErr(err error) int {
|
||||
switch err {
|
||||
case errEmptyRequest:
|
||||
return http.StatusBadRequest
|
||||
default:
|
||||
return http.StatusInternalServerError
|
||||
}
|
||||
}
|
||||
|
||||
func errorDecoder(r *http.Response) error {
|
||||
var w errorWrapper
|
||||
if err := json.NewDecoder(r.Body).Decode(&w); err != nil {
|
||||
return err
|
||||
}
|
||||
return errors.New(w.Error)
|
||||
}
|
||||
|
||||
type errorWrapper struct {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
func decodeRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
||||
var req newCommandRequest
|
||||
err := json.NewDecoder(io.LimitReader(r.Body, 10000)).Decode(&req)
|
||||
|
||||
@@ -122,13 +122,6 @@ func (db *DB) PushTopic() (string, error) {
|
||||
return topic, errors.Wrap(err, "get topic from push certificate")
|
||||
}
|
||||
|
||||
func isNotFound(err error) bool {
|
||||
if _, ok := err.(*notFound); ok {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type notFound struct {
|
||||
ResourceType string
|
||||
Message string
|
||||
|
||||
@@ -2,7 +2,6 @@ package connect
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/micromdm/mdm"
|
||||
@@ -19,9 +18,6 @@ type mdmConnectResponse struct {
|
||||
|
||||
func (r mdmConnectResponse) error() error { return r.Err }
|
||||
|
||||
// errInvalidMessageType is an invalid checking command.
|
||||
var errInvalidMessageType = errors.New("invalid message type")
|
||||
|
||||
type Endpoints struct {
|
||||
ConnectEndpoint endpoint.Endpoint
|
||||
}
|
||||
|
||||
@@ -29,10 +29,6 @@ type errorer interface {
|
||||
error() error
|
||||
}
|
||||
|
||||
type errorWrapper struct {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
func decodeRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
||||
var req mdmConnectRequest
|
||||
err := plist.NewDecoder(r.Body).Decode(&req)
|
||||
|
||||
@@ -55,11 +55,6 @@ type mdmOTAPhase2Phase3Request struct {
|
||||
p7 *pkcs7.PKCS7
|
||||
}
|
||||
|
||||
type mdmOTAEnrollResponse struct {
|
||||
Payload
|
||||
Err error `plist:"error,omitempty"`
|
||||
}
|
||||
|
||||
func MakeServerEndpoints(s Service, scepDepot *boltdepot.Depot) Endpoints {
|
||||
return Endpoints{
|
||||
GetEnrollEndpoint: MakeGetEnrollEndpoint(s),
|
||||
|
||||
@@ -2,13 +2,10 @@ package push
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
)
|
||||
|
||||
var errEmptyRequest = errors.New("request must contain UDID of the device")
|
||||
|
||||
type Endpoints struct {
|
||||
PushEndpoint endpoint.Endpoint
|
||||
}
|
||||
|
||||
@@ -46,27 +46,6 @@ func EncodeError(ctx context.Context, err error, w http.ResponseWriter) {
|
||||
})
|
||||
}
|
||||
|
||||
func codeFromErr(err error) int {
|
||||
switch err {
|
||||
case errEmptyRequest:
|
||||
return http.StatusBadRequest
|
||||
default:
|
||||
return http.StatusInternalServerError
|
||||
}
|
||||
}
|
||||
|
||||
func errorDecoder(r *http.Response) error {
|
||||
var w errorWrapper
|
||||
if err := json.NewDecoder(r.Body).Decode(&w); err != nil {
|
||||
return err
|
||||
}
|
||||
return errors.New(w.Error)
|
||||
}
|
||||
|
||||
type errorWrapper struct {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
func decodeRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
||||
var errBadRoute = errors.New("bad route")
|
||||
var req pushRequest
|
||||
|
||||
7
serve.go
7
serve.go
@@ -882,12 +882,6 @@ func mdmAuthSignMessageMiddleware(db *boltdepot.Depot, next http.Handler) http.H
|
||||
}
|
||||
}
|
||||
|
||||
func basicAuth(password string) string {
|
||||
const authUsername = "micromdm"
|
||||
auth := authUsername + ":" + password
|
||||
return base64.StdEncoding.EncodeToString([]byte(auth))
|
||||
}
|
||||
|
||||
func apiAuthMiddleware(token string, next http.Handler) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
_, password, ok := r.BasicAuth()
|
||||
@@ -897,7 +891,6 @@ func apiAuthMiddleware(token string, next http.Handler) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -139,10 +139,3 @@ type notFound struct {
|
||||
func (e *notFound) Error() string {
|
||||
return fmt.Sprintf("not found: %s %s", e.ResourceType, e.Message)
|
||||
}
|
||||
|
||||
func isNotFound(err error) bool {
|
||||
if _, ok := err.(*notFound); ok {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user