CategoryProgramming

fullstack web app-golang #6

f

So now as we did both our frontend and backend, you may think these should work together. But there’s a small problem. We’re gonna need to configure something called CORS in the backend. Again we’re gonna use a library go get "github.com/rs/cors" Now in our main.go file. //connect to db db.Connectmongo() // Init router r := mux.NewRouter() secretHandler := http...

fullstack web app-golang #5

f

So we basically managed to finish the state management in our app. Now lets add the basic routing. Again we need some npm libraries. npm i react-router react-router-dom Now open your app.js file. import Navbar from './components/main/NavBar' import Main from './components/main/Main' import Login from './components/Auth/Login' import Register from './components/Auth/Register' import Posts from '...

fullstack web app-golang #4

f

so lets start building the front end of our app. As I said we’re gonna use react here. This is our project structure: I think I gave all the files a good descriptive name. I’ll explain things along the way. But before doing anything. we’re gonna need 2 libraries. materialize-css and react-router. so install it with npm. materialize css To use materialize css you have to import...

fullstack web app-golang #3

f

So we already finished the authentication and all thats left to do is to add some posts. Remember what we’re trying to do is any authenticated users can post anything. And their posts are not monitored even by us. So there will be no relationship between our documents. Lets actually start coding. In posts.go which is inside models folder. we already wrote the schema package model import "go...

fullstack web app-golang #2

f

So basically we did everything except database stuffs in previous article. so let’s add database to the server. First lets connect our mongodb to our app. In db/connect.go. package db import ( "context" "fmt" "log" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) //connect to mongo // Set client options var clientOptions = options.Client()...

fullstack web app-golang #1

f

So as I already said we’re gonna create both the frontend and backend. First we’ll consider only on the backend and then we will write the front end. spoilers: close your eyes! Here’s the completed project code: frontend – backend- Use this as a reference to follow along the code or write alongside this article. lets start The project structure we’re gonna use will...

full stack app with golang-requirements

f

This article will tell you about the tech stack we’re gonna use for this project. As the title says this will be a complete a full stack app. webapp idea: Its pretty cliche to be honest. But I still thinks we can learn a lot from this project we’re gonna build. Its basically a website where anyone can post anything anonymously without the fear of people judging you. well obviously we...

understanding jwt in golang with a simple app

u

JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.(source: ) So basically whenever we want to use authentication, we can use this to attach data to the header. Here are some scenarios where JSON Web Tokens are useful: AuthorizationInformation Exchange What is the JSON Web Token structure? In its compact form, JSON Web...

introduction to websockets-socket.io

i

So we already know about how http methods work. We even build our own server. But one thing I haven’t talked for a quite while is this thing called websockets. Lets say you’re using facebook, and you just happens to recieve a notification or a message. But how does that work? At first you might think like, “we already know how this works! The server just sends a http response to...

Most common tags