Make api more restful
This commit is contained in:
parent
1ac4e9da64
commit
a2503d4b98
|
@ -29,7 +29,7 @@
|
|||
<div class="page-header">
|
||||
<h1>{{.Title}}</h1>
|
||||
</div>
|
||||
<form action="/save/redirect" method="post" class="form-horizontal">
|
||||
<form action="/p/redirect" method="post" class="form-horizontal">
|
||||
<fieldset>
|
||||
<div class="well" style="padding-top: 10px;">
|
||||
<div class="form-group is-empty" style="margin-top: 0px;">
|
||||
|
@ -471,11 +471,13 @@
|
|||
</fieldset>
|
||||
</form>
|
||||
<div class="well">
|
||||
<code>$ <command> | curl -F 'p=<-' https://p.pantsu.cat/save</code><br/>
|
||||
<code>https://p.pantsu.cat/save/(XML|JSON|HTML)</code><br/>
|
||||
<code>https://p.pantsu.cat/p/(PASTE)/(lang)</code><br/>
|
||||
<code>https://p.pantsu.cat/del/(PASTE)/(DELKEY)</code><br/>
|
||||
<code>pasteurl = urllib2.urlopen("https://p.pantsu.cat/save", "p="+ data).read()</code><br/>
|
||||
<code>$ <command> | curl -X POST -F 'p=<-' https://p.pantsu.cat/p</code><br/>
|
||||
<code>POST https://p.pantsu.cat/p/(XML|JSON|HTML)</code><br/>
|
||||
<code>GET: https://p.pantsu.cat/p/(PASTE)/(lang)</code><br/>
|
||||
<code>GET: https://p.pantsu.cat/raw/(PASTE)</code><br/>
|
||||
<code>GET: https://p.pantsu.cat/download/(PASTE)</code><br/>
|
||||
<code>GET: https://p.pantsu.cat/clone/(PASTE)</code><br/>
|
||||
<code>DEL: https://p.pantsu.cat/p/(PASTE)/(DELKEY)</code><br/>
|
||||
<p>Source: <a href="https://github.com/ewhal/Pastebin">Github</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<div class="page-header">
|
||||
<h1>Pantsu Paste</h1>
|
||||
</div>
|
||||
<form action="/save/redirect" method="post" class="form-horizontal">
|
||||
<form action="/p/redirect" method="post" class="form-horizontal">
|
||||
<fieldset>
|
||||
<div class="well" style="padding-top: 10px; resize: both;">
|
||||
<div class="form-group is-empty" style="margin-top: 0px;">
|
||||
|
@ -465,11 +465,13 @@
|
|||
</fieldset>
|
||||
</form>
|
||||
<div class="well">
|
||||
<code>$ <command> | curl -F 'p=<-' https://p.pantsu.cat/save</code><br/>
|
||||
<code>https://p.pantsu.cat/save/(XML|JSON|HTML)</code><br/>
|
||||
<code>https://p.pantsu.cat/p/(PASTE)/(lang)</code><br/>
|
||||
<code>https://p.pantsu.cat/del/(PASTE)/(DELKEY)</code><br/>
|
||||
<code>pasteurl = urllib2.urlopen("https://p.pantsu.cat/save", "p="+ data).read()</code><br/>
|
||||
<code>$ <command> | curl -X POST -F 'p=<-' https://p.pantsu.cat/p</code><br/>
|
||||
<code>POST https://p.pantsu.cat/p/(XML|JSON|HTML)</code><br/>
|
||||
<code>GET: https://p.pantsu.cat/p/(PASTE)/(lang)</code><br/>
|
||||
<code>GET: https://p.pantsu.cat/raw/(PASTE)</code><br/>
|
||||
<code>GET: https://p.pantsu.cat/download/(PASTE)</code><br/>
|
||||
<code>GET: https://p.pantsu.cat/clone/(PASTE)</code><br/>
|
||||
<code>DEL: https://p.pantsu.cat/p/(PASTE)/(DELKEY)</code><br/>
|
||||
<p>Source: <a href="https://github.com/ewhal/Pastebin">Github</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
15
pastebin.go
15
pastebin.go
|
@ -381,14 +381,13 @@ func rootHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
func main() {
|
||||
router := mux.NewRouter()
|
||||
router.HandleFunc("/p/{pasteId}", pasteHandler)
|
||||
router.HandleFunc("/raw/{pasteId}", rawHandler)
|
||||
router.HandleFunc("/p/{pasteId}/{lang}", pasteHandler)
|
||||
router.HandleFunc("/clone/{pasteId}", cloneHandler)
|
||||
router.HandleFunc("/download/{pasteId}", downloadHandler)
|
||||
router.HandleFunc("/save", saveHandler)
|
||||
router.HandleFunc("/save/{output}", saveHandler)
|
||||
router.HandleFunc("/del/{pasteId}/{delKey}", delHandler)
|
||||
router.HandleFunc("/p/{pasteId}", pasteHandler).Methods("GET")
|
||||
router.HandleFunc("/raw/{pasteId}", rawHandler).Methods("GET")
|
||||
router.HandleFunc("/p/{pasteId}/{lang}", pasteHandler).Methods("GET")
|
||||
router.HandleFunc("/clone/{pasteId}", cloneHandler).Methods("GET")
|
||||
router.HandleFunc("/download/{pasteId}", downloadHandler).Methods("GET")
|
||||
router.HandleFunc("/p/{output}", saveHandler).Methods("POST")
|
||||
router.HandleFunc("/p/{pasteId}/{delKey}", delHandler).Methods("DELETE")
|
||||
router.HandleFunc("/", rootHandler)
|
||||
err := http.ListenAndServe(PORT, router)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue