mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-18 18:17:03 +00:00
Reorganize URI routes to be more RESTful
This commit is contained in:
@@ -1 +1 @@
|
||||
curl -i -H "Accept: application/json" --noproxy localhost http://localhost:9000/mailbox/list/$1
|
||||
curl -i -H "Accept: application/json" --noproxy localhost http://localhost:9000/mailbox/$1
|
||||
|
||||
1
bin/message-delete.sh
Executable file
1
bin/message-delete.sh
Executable file
@@ -0,0 +1 @@
|
||||
curl -i -H "Accept: application/json" --noproxy localhost -X DELETE http://localhost:9000/mailbox/$1/$2
|
||||
@@ -1 +1 @@
|
||||
curl -i -H "Accept: application/json" --noproxy localhost http://localhost:9000/mailbox/source/$1/$2
|
||||
curl -i -H "Accept: application/json" --noproxy localhost http://localhost:9000/mailbox/$1/$2/source
|
||||
@@ -15,14 +15,14 @@
|
||||
function() {
|
||||
$('.listEntry').removeClass("listEntrySelected")
|
||||
$(this).addClass("listEntrySelected")
|
||||
$('#emailContent').load('/mailbox/show/{{.name}}/' + this.id)
|
||||
$('#emailContent').load('/mailbox/{{.name}}/' + this.id)
|
||||
}
|
||||
)
|
||||
$("#messageList").slideDown()
|
||||
}
|
||||
|
||||
function loadList() {
|
||||
$('#messageList').load("/mailbox/list/{{.name}}", listLoaded)
|
||||
$('#messageList').load("/mailbox/{{.name}}", listLoaded)
|
||||
}
|
||||
|
||||
function reloadList() {
|
||||
@@ -38,20 +38,20 @@
|
||||
function deleteMessage(id) {
|
||||
$('#emailContent').empty()
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/mailbox/delete/{{.name}}/' + id,
|
||||
type: 'DELETE',
|
||||
url: '/mailbox/{{.name}}/' + id,
|
||||
success: reloadList
|
||||
})
|
||||
}
|
||||
|
||||
function htmlView(id) {
|
||||
window.open('/mailbox/html/{{.name}}/' + id, '_blank',
|
||||
window.open('/mailbox/{{.name}}/' + id + "/html", '_blank',
|
||||
'width=800,height=600,' +
|
||||
'menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes')
|
||||
}
|
||||
|
||||
function messageSource(id) {
|
||||
window.open('/mailbox/source/{{.name}}/' + id, '_blank',
|
||||
window.open('/mailbox/{{.name}}/' + id + "/source", '_blank',
|
||||
'width=800,height=600,' +
|
||||
'menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no')
|
||||
}
|
||||
|
||||
@@ -55,13 +55,13 @@ func MailboxList(w http.ResponseWriter, req *http.Request, ctx *Context) (err er
|
||||
}
|
||||
}
|
||||
return RenderJson(w, jmessages)
|
||||
} else {
|
||||
return RenderPartial("mailbox/_list.html", w, map[string]interface{}{
|
||||
"ctx": ctx,
|
||||
"name": name,
|
||||
"messages": messages,
|
||||
})
|
||||
}
|
||||
|
||||
return RenderPartial("mailbox/_list.html", w, map[string]interface{}{
|
||||
"ctx": ctx,
|
||||
"name": name,
|
||||
"messages": messages,
|
||||
})
|
||||
}
|
||||
|
||||
func MailboxShow(w http.ResponseWriter, req *http.Request, ctx *Context) (err error) {
|
||||
@@ -234,6 +234,11 @@ func MailboxDelete(w http.ResponseWriter, req *http.Request, ctx *Context) (err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if ctx.IsJson {
|
||||
return RenderJson(w, "OK")
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
io.WriteString(w, "OK")
|
||||
return nil
|
||||
|
||||
@@ -35,11 +35,11 @@ func setupRoutes(cfg config.WebConfig) {
|
||||
r.Path("/").Handler(handler(RootIndex)).Name("RootIndex").Methods("GET")
|
||||
r.Path("/status").Handler(handler(RootStatus)).Name("RootStatus").Methods("GET")
|
||||
r.Path("/mailbox").Handler(handler(MailboxIndex)).Name("MailboxIndex").Methods("GET")
|
||||
r.Path("/mailbox/list/{name}").Handler(handler(MailboxList)).Name("MailboxList").Methods("GET")
|
||||
r.Path("/mailbox/show/{name}/{id}").Handler(handler(MailboxShow)).Name("MailboxShow").Methods("GET")
|
||||
r.Path("/mailbox/html/{name}/{id}").Handler(handler(MailboxHtml)).Name("MailboxHtml").Methods("GET")
|
||||
r.Path("/mailbox/source/{name}/{id}").Handler(handler(MailboxSource)).Name("MailboxSource").Methods("GET")
|
||||
r.Path("/mailbox/delete/{name}/{id}").Handler(handler(MailboxDelete)).Name("MailboxDelete").Methods("POST")
|
||||
r.Path("/mailbox/{name}").Handler(handler(MailboxList)).Name("MailboxList").Methods("GET")
|
||||
r.Path("/mailbox/{name}/{id}").Handler(handler(MailboxShow)).Name("MailboxShow").Methods("GET")
|
||||
r.Path("/mailbox/{name}/{id}/html").Handler(handler(MailboxHtml)).Name("MailboxHtml").Methods("GET")
|
||||
r.Path("/mailbox/{name}/{id}/source").Handler(handler(MailboxSource)).Name("MailboxSource").Methods("GET")
|
||||
r.Path("/mailbox/{name}/{id}").Handler(handler(MailboxDelete)).Name("MailboxDelete").Methods("DELETE")
|
||||
r.Path("/mailbox/dattach/{name}/{id}/{num}/{file}").Handler(handler(MailboxDownloadAttach)).Name("MailboxDownloadAttach").Methods("GET")
|
||||
r.Path("/mailbox/vattach/{name}/{id}/{num}/{file}").Handler(handler(MailboxViewAttach)).Name("MailboxViewAttach").Methods("GET")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user