Base Flutter Project

This commit is contained in:
2021-01-06 14:36:09 -05:00
parent 5b068f607c
commit 24c4adf910
79 changed files with 1891 additions and 174 deletions

39
routes/middlewares.go Normal file
View File

@@ -0,0 +1,39 @@
package routes
import (
"net/http"
"log"
"os"
)
type Middleware func(http.HandlerFunc) http.HandlerFunc
func MultipleMiddleware(h http.HandlerFunc, m ...Middleware) http.HandlerFunc {
if len(m) < 1 {
return h
}
wrapped := h
for i := len(m) - 1; i >= 0; i-- {
wrapped = m[i](wrapped)
}
return wrapped
}
func authMiddleware(h http.HandlerFunc) http.HandlerFunc {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
log.SetOutput(os.Stdout)
log.Println(r.Method, r.URL)
h.ServeHTTP(w, r)
})
}
func logMiddleware(h http.HandlerFunc) http.HandlerFunc {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
log.SetOutput(os.Stdout)
log.Println(r.Method, r.URL)
h.ServeHTTP(w, r)
})
}

View File

@@ -3,18 +3,24 @@ package routes
import (
"net/http"
"fmt"
"reichard.io/imagini/internal/db"
"github.com/tus/tusd/pkg/filestore"
tusd "github.com/tus/tusd/pkg/handler"
)
func RegisterRoutes() {
// Regular Handlers
http.HandleFunc("/hello", helloHandler)
http.HandleFunc("/Users", usersHandler)
http.HandleFunc("/Tags", tagsHandler)
// Uploads Handler
http.Handle("/uploads/", uploadsHandler())
}
func tagsHandler(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()
filters, present := query["filters"]
}
func uploadsHandler() http.Handler {
store := filestore.FileStore{
Path: "./uploads",
@@ -42,6 +48,40 @@ func uploadsHandler() http.Handler {
return http.StripPrefix("/uploads/", handler)
}
func processMedia() {
var mi db.MediaItem
// TODO:
// - Derive Magic -> mediaType
// - Create Thumbnail
// - Pull EXIF
// - EXIFDate
// - Latitude
// - Longitude
// - TensorFlow Classification
// - https://outcrawl.com/image-recognition-api-go-tensorflow
// - Update Tags / MediaTags Table
// - Save Image
// - Update MediaItems Table
// import "github.com/disintegration/imaging"
//
// img, err := imaging.Open("original.jpg", imaging.AutoOrientation(true))
// if err != nil {
// return nil, err
// }
//
// img = imaging.Fit(img, 240, 160, imaging.Lanczos)
// err = imaging.Save(img, "thumbnail.jpg")
}
func helloHandler(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/hello" {
http.Error(w, "404 not found.", http.StatusNotFound)

10
routes/users.go Normal file
View File

@@ -0,0 +1,10 @@
package routes
import (
"net/http"
)
func usersHandler(w http.ResponseWriter, r *http.Request) {
// TODO:
// - Get current UserID
}