mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-11 18:32:50 +00:00
got angular routing working - starting on html components
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
//"encoding/json"
|
||||
"fmt"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// IndexGET displays the home page
|
||||
func NotFound404(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||
|
||||
http.Redirect(w, r, "/404.html", 404)
|
||||
|
||||
fmt.Fprint(w, "test")
|
||||
}
|
||||
29
controller/api/testApi.go
Normal file
29
controller/api/testApi.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ApiCall struct {
|
||||
Fname string
|
||||
Lname string
|
||||
}
|
||||
|
||||
// Redirect to discord
|
||||
func TestApiCall(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
|
||||
s := new(ApiCall)
|
||||
|
||||
s.Fname = ps.ByName("fname")
|
||||
s.Lname = ps.ByName("lname")
|
||||
|
||||
response, _ := json.MarshalIndent(s, "", " ")
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
fmt.Fprint(w, string(response))
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
//"encoding/json"
|
||||
"fmt"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// IndexGET displays the home page
|
||||
func IndexGet(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
response := "{\"test\" : 123}"
|
||||
|
||||
fmt.Fprint(w, response)
|
||||
|
||||
}
|
||||
13
controller/redirect.go
Normal file
13
controller/redirect.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Redirect to discord
|
||||
func Discord(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||
|
||||
http.Redirect(w, r, "https://discordapp.com/invite/0Z2tzxKECEj2BHwj", 301)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user