diff --git a/APIv1.md b/APIv1.md new file mode 100644 index 0000000..7366cbd --- /dev/null +++ b/APIv1.md @@ -0,0 +1,48 @@ +Go-MailHog API v1 +================= + +The v1 API is a RESTful HTTP JSON API. + +### GET /v1/api/messages + +Lists all messages excluding message content + +### DELETE /v1/api/messages + +Deletes all messages + +Returns a ```200``` response code if message deletion was successful. + +### GET /v1/api/messages/{ message_id } + +Returns an individual message including message content + +### DELETE /v1/api/messages/{ message_id } + +Delete an individual message + +Returns a ```200``` response code if message deletion was successful. + +### GET /v1/api/messages/{ message_id }/download + +Download the complete message + +### GET /v1/api/messages/{ message_id }/mime/part/{ part_index }/download + +Download a MIME part + +### POST /v1/api/messages/{ message_id }/release + +Release the message to an SMTP server + +Send a JSON body specifying the recipient, SMTP hostname and port number: + +```json +{ + "Host": "mail.example.com", + "Post": "25", + "Email": "someone@example.com" +} +``` + +Returns a ```200``` response code if message delivery was successful. diff --git a/README.md b/README.md index 0daeaa0..af8921c 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ server will start on port 8025. * Web interface to view messages (plain text, HTML or source) * Release messages to real SMTP servers * HTTP API to list, retrieve and delete messages + * See (APIv1 documentation)[APIv1.md] for more information * Multipart MIME support * Download individual MIME parts * In-memory message storage diff --git a/assets/js/controllers.js b/assets/js/controllers.js index 548a6bc..81a05b5 100644 --- a/assets/js/controllers.js +++ b/assets/js/controllers.js @@ -208,7 +208,7 @@ mailhogApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout) { $scope.deleteAllConfirm = function() { $('#confirm-delete-all').modal('hide'); var e = $scope.startEvent("Deleting all messages", null, "glyphicon-remove-circle"); - $http.post('/api/v1/messages/delete').success(function() { + $http.delete('/api/v1/messages').success(function() { $scope.refresh(); $scope.preview = null; e.done() @@ -217,7 +217,7 @@ mailhogApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout) { $scope.deleteOne = function(message) { var e = $scope.startEvent("Deleting message", message.Id, "glyphicon-remove"); - $http.post('/api/v1/messages/' + message.Id + '/delete').success(function() { + $http.delete('/api/v1/messages/' + message.Id).success(function() { if($scope.preview._id == message._id) $scope.preview = null; $scope.refresh(); e.done(); diff --git a/bindata.go b/bindata.go index d0c59e7..e5c80e5 100644 --- a/bindata.go +++ b/bindata.go @@ -452,140 +452,140 @@ func assets_js_controllers_js() ([]byte, error) { 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x00, 0xff, 0xec, 0x58, 0x5b, 0x6b, 0x1b, 0xc9, 0x12, 0x7e, 0x96, 0x7e, 0x45, 0x9f, 0x39, 0x06, 0xcd, 0xc4, 0xd2, 0xc8, 0x86, 0xc3, 0x79, 0xb0, 0xc8, 0x39, 0x64, 0xed, - 0x84, 0x18, 0x62, 0x36, 0x24, 0x79, 0x58, 0x70, 0xcc, 0xd2, 0x9e, 0x29, - 0x69, 0x86, 0xf4, 0x5c, 0xe8, 0x6e, 0x49, 0x31, 0x41, 0xff, 0x7d, 0xab, - 0xa7, 0x6f, 0x73, 0x93, 0x6c, 0xb2, 0xec, 0xc3, 0xc2, 0x9a, 0x90, 0xd1, - 0x74, 0x55, 0x57, 0x55, 0x7f, 0x75, 0xed, 0xd9, 0x51, 0x4e, 0x0a, 0x9a, - 0xb3, 0xac, 0xda, 0xbc, 0xa9, 0x6b, 0xf2, 0x9a, 0xd0, 0x72, 0xb3, 0x65, - 0x94, 0xc7, 0x45, 0x95, 0x6e, 0x19, 0x84, 0x33, 0x4f, 0x9c, 0xcd, 0xc9, - 0xfd, 0x43, 0xb4, 0x9a, 0x4e, 0xd7, 0xdb, 0x32, 0x91, 0x79, 0x55, 0x92, - 0xcd, 0x36, 0x4f, 0xc3, 0x88, 0xfc, 0x98, 0x12, 0xe2, 0xd6, 0xc4, 0x7f, - 0xcc, 0x0a, 0x21, 0x1c, 0xe4, 0x96, 0x97, 0xe4, 0x8e, 0xca, 0x2c, 0x5e, - 0xb3, 0xaa, 0xe2, 0x61, 0x78, 0x49, 0xce, 0xf5, 0x3b, 0xa7, 0x65, 0x5a, - 0x15, 0x61, 0x14, 0x91, 0x57, 0xe4, 0xe2, 0xfb, 0xe5, 0x05, 0xfe, 0x45, - 0xcd, 0xa6, 0xd6, 0x5f, 0x2c, 0xab, 0xcf, 0x92, 0xe7, 0xe5, 0x26, 0xbc, - 0xfc, 0xef, 0x90, 0x28, 0xb6, 0x8f, 0xc2, 0x50, 0xd1, 0x28, 0x42, 0x0e, - 0x53, 0xa7, 0xb1, 0xb1, 0xe1, 0xdc, 0x3e, 0x66, 0x8b, 0xd9, 0xa9, 0x17, - 0x2f, 0x78, 0x8c, 0xa5, 0xf5, 0x58, 0x4d, 0x0f, 0xd3, 0xa9, 0x87, 0x23, - 0x4e, 0xaa, 0x52, 0xf2, 0x8a, 0x31, 0xe0, 0xe1, 0xec, 0x0e, 0x97, 0xaf, - 0x25, 0x67, 0x88, 0x91, 0x43, 0x22, 0x3c, 0x13, 0x49, 0x55, 0xc3, 0x9c, - 0x9c, 0x65, 0x52, 0xd6, 0xf8, 0x10, 0x89, 0x7a, 0x91, 0x79, 0x01, 0xd5, - 0x56, 0x6a, 0x90, 0x34, 0x4b, 0x9c, 0xd0, 0x24, 0x03, 0x04, 0xff, 0xc7, - 0x61, 0xe5, 0x17, 0x6b, 0x0e, 0xbb, 0x1c, 0xf6, 0x6f, 0x18, 0x7b, 0x0f, - 0x34, 0x05, 0x2e, 0x90, 0x61, 0x4d, 0x99, 0x00, 0x74, 0x81, 0x63, 0x82, - 0x1d, 0x94, 0x52, 0x7c, 0x84, 0x32, 0x45, 0x24, 0xfa, 0x12, 0x1a, 0xe2, - 0x75, 0xb5, 0x2d, 0x25, 0x52, 0x2e, 0xfa, 0x84, 0x9b, 0xaa, 0x84, 0xb1, - 0xf5, 0x77, 0x78, 0x16, 0x48, 0x35, 0xc5, 0x93, 0x84, 0xa4, 0x5c, 0xbe, - 0x55, 0x74, 0x65, 0x86, 0x39, 0x63, 0x58, 0xd2, 0x02, 0xcf, 0x44, 0xf9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x62, 0x13, 0x5e, + 0xff, 0xb7, 0x4f, 0x14, 0xdb, 0x27, 0x61, 0xa8, 0x68, 0x14, 0x21, 0x87, + 0xb1, 0xd3, 0x58, 0xdb, 0x70, 0x69, 0x1f, 0x93, 0xd9, 0xe4, 0xd4, 0x8b, + 0x17, 0x3c, 0xc4, 0xd2, 0x78, 0x2c, 0xc6, 0x87, 0xf1, 0xd8, 0xc3, 0x11, + 0xaf, 0xca, 0x42, 0xf2, 0x92, 0x31, 0xe0, 0xe1, 0x64, 0x89, 0xcb, 0xb7, + 0x92, 0x33, 0xc4, 0xc8, 0x21, 0x11, 0x5e, 0x88, 0x55, 0x59, 0xc1, 0x94, + 0x5c, 0xa4, 0x52, 0x56, 0xf8, 0x10, 0x2b, 0xf5, 0x22, 0xb3, 0x1c, 0xca, + 0xad, 0xd4, 0x20, 0x69, 0x96, 0x78, 0x45, 0x57, 0x29, 0x20, 0xf8, 0x3f, + 0x0e, 0x0b, 0xbf, 0x58, 0x71, 0xd8, 0x65, 0xb0, 0x7f, 0xc3, 0xd8, 0x7b, + 0xa0, 0x09, 0x70, 0x81, 0x0c, 0x6b, 0xca, 0x04, 0xa0, 0x0b, 0x1c, 0x13, + 0xec, 0xa0, 0x90, 0xe2, 0x23, 0x14, 0x09, 0x22, 0xd1, 0x95, 0x50, 0x13, + 0x6f, 0xcb, 0x6d, 0x21, 0x91, 0x72, 0xd5, 0x25, 0xdc, 0x95, 0x05, 0x0c, + 0xad, 0xbf, 0xc3, 0xb3, 0x40, 0xa2, 0x29, 0x9e, 0x24, 0x24, 0xe5, 0xf2, + 0xad, 0xa2, 0x2b, 0x33, 0xcc, 0x19, 0xc3, 0x82, 0xe6, 0x78, 0x26, 0xca, + 0x37, 0x62, 0x4a, 0x36, 0xec, 0xb9, 0x4a, 0x33, 0x44, 0xc5, 0xfa, 0x5f, + 0xc5, 0x16, 0xdc, 0xdf, 0x21, 0xbf, 0x0e, 0x94, 0x45, 0xbd, 0x8a, 0x0c, + 0xa2, 0x64, 0x10, 0xb3, 0x72, 0x13, 0x06, 0x9f, 0x95, 0x54, 0x65, 0x79, + 0xad, 0x99, 0x4c, 0x02, 0xc4, 0x5a, 0xc9, 0xc4, 0x47, 0x30, 0x21, 0xfb, + 0x4c, 0xa6, 0x24, 0x4b, 0xf4, 0xb2, 0x92, 0xa4, 0x56, 0x83, 0xc8, 0x0b, + 0x57, 0x07, 0x36, 0xfe, 0xcb, 0x92, 0x1b, 0xc5, 0x32, 0x35, 0xaf, 0x4a, + 0xc8, 0x4d, 0xfd, 0xbf, 0x5d, 0xa9, 0x0f, 0x00, 0xc8, 0x55, 0xc0, 0x9e, + 0xdc, 0x51, 0x09, 0x61, 0x64, 0x49, 0xab, 0x32, 0xaf, 0x18, 0x48, 0xdc, + 0x50, 0xe3, 0x6b, 0x97, 0xd7, 0x35, 0x10, 0x9d, 0x45, 0x75, 0xd6, 0x1b, + 0x7d, 0x62, 0xb3, 0xe2, 0xce, 0x7d, 0xe3, 0x7f, 0x3a, 0x1a, 0xc8, 0x5b, + 0x46, 0x05, 0xee, 0x70, 0x90, 0x45, 0xce, 0x64, 0x42, 0xe6, 0x73, 0xf2, + 0xee, 0xfe, 0xb7, 0xe5, 0x5b, 0xf2, 0x94, 0x49, 0x34, 0x56, 0xc8, 0x67, + 0x47, 0xca, 0xd6, 0xa1, 0x4c, 0x33, 0x11, 0x6b, 0x23, 0x9a, 0x9b, 0x5c, + 0x98, 0x07, 0x4f, 0x9b, 0x59, 0x82, 0xf9, 0x0a, 0x3c, 0x70, 0xc4, 0x43, + 0x4f, 0x80, 0x3d, 0xdc, 0x51, 0x11, 0x62, 0xbb, 0x5a, 0x81, 0x10, 0x43, + 0x32, 0x1a, 0x5c, 0x7b, 0xca, 0x0b, 0x74, 0x54, 0xb0, 0x50, 0x46, 0x57, + 0x3a, 0xde, 0x0c, 0xdf, 0xc1, 0x9e, 0x36, 0xc1, 0x88, 0x3a, 0x7a, 0xd2, + 0x04, 0x94, 0x15, 0x83, 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ff, 0x6b, 0x2c, 0x3b, 0xd9, 0xb3, 0x17, 0x00, 0x00, }, "assets/js/controllers.js", ) diff --git a/mailhog/http/api/v1.go b/mailhog/http/api/v1.go index eab88bd..0c8b270 100644 --- a/mailhog/http/api/v1.go +++ b/mailhog/http/api/v1.go @@ -33,13 +33,13 @@ func CreateAPIv1(exitCh chan int, conf *config.Config, server *http.Server) *API server: server, } - server.Handler.(*handler.RegexpHandler).HandleFunc(regexp.MustCompile("^/api/v1/messages/?$"), apiv1.messages) - server.Handler.(*handler.RegexpHandler).HandleFunc(regexp.MustCompile("^/api/v1/messages/delete/?$"), apiv1.delete_all) - server.Handler.(*handler.RegexpHandler).HandleFunc(regexp.MustCompile("^/api/v1/messages/([0-9a-f]+)/?$"), apiv1.message) - server.Handler.(*handler.RegexpHandler).HandleFunc(regexp.MustCompile("^/api/v1/messages/([0-9a-f]+)/delete/?$"), apiv1.delete_one) - server.Handler.(*handler.RegexpHandler).HandleFunc(regexp.MustCompile("^/api/v1/messages/([0-9a-f]+)/download/?$"), apiv1.download) - server.Handler.(*handler.RegexpHandler).HandleFunc(regexp.MustCompile("^/api/v1/messages/([0-9a-f]+)/mime/part/(\\d+)/download/?$"), apiv1.download_part) - server.Handler.(*handler.RegexpHandler).HandleFunc(regexp.MustCompile("^/api/v1/messages/([0-9a-f]+)/release/?$"), apiv1.release_one) + server.Handler.(*handler.RegexpHandler).HandleFunc([]string{"GET"},regexp.MustCompile("^/api/v1/messages/?$"), apiv1.messages) + server.Handler.(*handler.RegexpHandler).HandleFunc([]string{"DELETE"},regexp.MustCompile("^/api/v1/messages/?$"), apiv1.delete_all) + server.Handler.(*handler.RegexpHandler).HandleFunc([]string{"GET"},regexp.MustCompile("^/api/v1/messages/([0-9a-f]+)/?$"), apiv1.message) + server.Handler.(*handler.RegexpHandler).HandleFunc([]string{"DELETE"},regexp.MustCompile("^/api/v1/messages/([0-9a-f]+)/?$"), apiv1.delete_one) + server.Handler.(*handler.RegexpHandler).HandleFunc([]string{"GET"},regexp.MustCompile("^/api/v1/messages/([0-9a-f]+)/download/?$"), apiv1.download) + server.Handler.(*handler.RegexpHandler).HandleFunc([]string{"GET"},regexp.MustCompile("^/api/v1/messages/([0-9a-f]+)/mime/part/(\\d+)/download/?$"), apiv1.download_part) + server.Handler.(*handler.RegexpHandler).HandleFunc([]string{"POST"},regexp.MustCompile("^/api/v1/messages/([0-9a-f]+)/release/?$"), apiv1.release_one) return apiv1 } @@ -65,6 +65,7 @@ func (apiv1 *APIv1) messages(w http.ResponseWriter, r *http.Request, route *hand } func (apiv1 *APIv1) message(w http.ResponseWriter, r *http.Request, route *handler.Route) { + match := route.Pattern.FindStringSubmatch(r.URL.Path) id := match[1] log.Printf("[APIv1] GET /api/v1/messages/%s\n", id) @@ -148,7 +149,7 @@ func (apiv1 *APIv1) download_part(w http.ResponseWriter, r *http.Request, route } func (apiv1 *APIv1) delete_all(w http.ResponseWriter, r *http.Request, route *handler.Route) { - log.Println("[APIv1] POST /api/v1/messages/delete") + log.Println("[APIv1] POST /api/v1/messages") w.Header().Set("Content-Type", "text/json") switch apiv1.config.Storage.(type) { diff --git a/mailhog/http/handler/regexp.go b/mailhog/http/handler/regexp.go index 5e9d7a5..a5e6cda 100644 --- a/mailhog/http/handler/regexp.go +++ b/mailhog/http/handler/regexp.go @@ -8,6 +8,7 @@ import ( // http://stackoverflow.com/questions/6564558/wildcards-in-the-pattern-for-http-handlefunc type Route struct { + Methods map[string]int Pattern *regexp.Regexp Handler HandlerFunc } @@ -23,19 +24,30 @@ type RegexpHandler struct { routes []*Route } -func (h *RegexpHandler) Handler(pattern *regexp.Regexp, handler HandlerFunc) { - h.routes = append(h.routes, &Route{pattern, handler}) +func (h *RegexpHandler) Handler(methods []string, pattern *regexp.Regexp, handler HandlerFunc) { + m := make(map[string]int,0) + for _, v := range methods { + m[v] = 1 + } + h.routes = append(h.routes, &Route{m, pattern, handler}) } -func (h *RegexpHandler) HandleFunc(pattern *regexp.Regexp, handler func(http.ResponseWriter, *http.Request, *Route)) { - h.routes = append(h.routes, &Route{pattern, HandlerFunc(handler)}) +func (h *RegexpHandler) HandleFunc(methods []string, pattern *regexp.Regexp, handler func(http.ResponseWriter, *http.Request, *Route)) { + m := make(map[string]int,0) + for _, v := range methods { + m[v] = 1 + } + h.routes = append(h.routes, &Route{m, pattern, HandlerFunc(handler)}) } func (h *RegexpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { for _, route := range h.routes { if route.Pattern.MatchString(r.URL.Path) { - route.Handler.ServeHTTP(w, r, route) - return + _, ok := route.Methods[r.Method] + if ok { + route.Handler.ServeHTTP(w, r, route) + return + } } } // no pattern matched; send 404 response diff --git a/mailhog/http/server.go b/mailhog/http/server.go index 086366f..74d8a0d 100644 --- a/mailhog/http/server.go +++ b/mailhog/http/server.go @@ -72,12 +72,12 @@ func Start(exitCh chan int, conf *config.Config) { Handler: &handler.RegexpHandler{}, } - server.Handler.(*handler.RegexpHandler).HandleFunc(regexp.MustCompile("^/exit/?$"), web_exit) - server.Handler.(*handler.RegexpHandler).HandleFunc(regexp.MustCompile("^/js/controllers.js$"), web_jscontroller) - server.Handler.(*handler.RegexpHandler).HandleFunc(regexp.MustCompile("^/images/hog.png$"), web_imgcontroller) - server.Handler.(*handler.RegexpHandler).HandleFunc(regexp.MustCompile("^/images/github.png$"), web_img_github) - server.Handler.(*handler.RegexpHandler).HandleFunc(regexp.MustCompile("^/images/ajax-loader.gif$"), web_img_ajaxloader) - server.Handler.(*handler.RegexpHandler).HandleFunc(regexp.MustCompile("^/$"), web_index) + server.Handler.(*handler.RegexpHandler).HandleFunc([]string{"GET"},regexp.MustCompile("^/exit/?$"), web_exit) + server.Handler.(*handler.RegexpHandler).HandleFunc([]string{"GET"},regexp.MustCompile("^/js/controllers.js$"), web_jscontroller) + server.Handler.(*handler.RegexpHandler).HandleFunc([]string{"GET"},regexp.MustCompile("^/images/hog.png$"), web_imgcontroller) + server.Handler.(*handler.RegexpHandler).HandleFunc([]string{"GET"},regexp.MustCompile("^/images/github.png$"), web_img_github) + server.Handler.(*handler.RegexpHandler).HandleFunc([]string{"GET"},regexp.MustCompile("^/images/ajax-loader.gif$"), web_img_ajaxloader) + server.Handler.(*handler.RegexpHandler).HandleFunc([]string{"GET"},regexp.MustCompile("^/$"), web_index) api.CreateAPIv1(exitCh, conf, server)