mirror of
https://gitlab.com/foxixus/neomovies-api.git
synced 2025-10-28 18:08:51 +05:00
feat(api): add unified models, mappers, and prefixed routes (movie/tv/search)
This commit is contained in:
23
pkg/handlers/unified_helpers.go
Normal file
23
pkg/handlers/unified_helpers.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
func muxVars(r *http.Request) map[string]string { return mux.Vars(r) }
|
||||
|
||||
func writeJSON(w http.ResponseWriter, status int, v interface{}) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(status)
|
||||
_ = json.NewEncoder(w).Encode(v)
|
||||
}
|
||||
|
||||
type metaEnvelope struct {
|
||||
FetchedAt time.Time `json:"fetchedAt"`
|
||||
APIVersion string `json:"apiVersion"`
|
||||
ResponseTime int64 `json:"responseTime"`
|
||||
}
|
||||
Reference in New Issue
Block a user