stub out pastebin
This commit is contained in:
parent
b6b58fe2b3
commit
a5bef3cd30
8 changed files with 366 additions and 12 deletions
48
pastebin.go
Normal file
48
pastebin.go
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
package pastebin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/barakmich/ussher"
|
||||
"github.com/spf13/viper"
|
||||
bolt "go.etcd.io/bbolt"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
type pastebin struct {
|
||||
db *bolt.DB
|
||||
datadir string
|
||||
}
|
||||
|
||||
func (p *pastebin) HandleExec(appstring string, conn *ssh.ServerConn, channel ssh.Channel) {
|
||||
|
||||
}
|
||||
|
||||
func (p *pastebin) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
if req.Method != http.MethodGet {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
id := req.URL.Path
|
||||
fmt.Println("got id", id)
|
||||
}
|
||||
|
||||
func RegisterPastebin(config *ussher.Config, configNS *viper.Viper) error {
|
||||
path, err := filepath.Abs(configNS.GetString("datadir"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p := &pastebin{
|
||||
datadir: path,
|
||||
}
|
||||
db, err := bolt.Open(filepath.Join(p.datadir, "index.db"), 0600, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.db = db
|
||||
|
||||
config.HTTPMux.Handle("/p/", p)
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue