diff --git a/app.js b/app.js index 8e53fa7..a27fcdd 100644 --- a/app.js +++ b/app.js @@ -5,6 +5,9 @@ const fs = require('fs') const path = require('path') const app = express() + +app.use(express.static('public')) + app.set('view engine', 'ejs') app.get('/', (req, res) => { diff --git a/posts/basic-http-routing-in-golang.html b/posts/basic-http-routing-in-golang.html index 562f64e..ea4cfb6 100644 --- a/posts/basic-http-routing-in-golang.html +++ b/posts/basic-http-routing-in-golang.html @@ -2,7 +2,7 @@ use of external libraries for even the most basic tasks. For example, with JavaScript, most inexperienced developers seem to use jQuery to do simple tasks like selecting an element and replacing its contents. When you and I both know jQuery is way overkill for such a task. - See my article on Vanilla JS basics..

+ See my article on Vanilla JS basics..

I believe that in order to be considered an expert in a language, you must at least be able to demonstrate using the core language to achieve your goal. In our current case, HTTP routing. Now to be clear, I don't think you need to write everything from scratch all the time, but you should have a firm grasp on what is available by the core language, and when you are @@ -15,6 +15,8 @@ level basics first. See A Tour of Go.

Let's begin

+

The accompanying repo for the code produced in this article is located + on github.

Step 1

Here is our basic folder structure for this basic http routing example:

    basic-http-routing-in-golang/
@@ -53,7 +55,7 @@
     http.ResponseWriter and a message to display. Our browser will now look like this when we visit the
     /url endpoint.

- Browser Output for Step 2 - Hellp HTTP + Browser Output for Step 2 - Hellp HTTP

Here is what main.go looks like at this point:

diff --git a/posts/basic-http-routing-in-golang.md b/posts/basic-http-routing-in-golang.md index 5ecf736..969a601 100644 --- a/posts/basic-http-routing-in-golang.md +++ b/posts/basic-http-routing-in-golang.md @@ -1,4 +1,4 @@ -Golang is incredibly powerful. Its standard library has so much to offer, but I think other languages have encouraged the use of external libraries for even the most basic tasks. For example, with JavaScript, most inexperienced developers seem to use jQuery to do simple tasks like selecting an element and replacing its contents. When you and I both know jQuery is way overkill for such a task. [See my article on Vanilla JS basics.](/coming-soon). +Golang is incredibly powerful. Its standard library has so much to offer, but I think other languages have encouraged the use of external libraries for even the most basic tasks. For example, with JavaScript, most inexperienced developers seem to use jQuery to do simple tasks like selecting an element and replacing its contents. When you and I both know jQuery is way overkill for such a task. [See my article on Vanilla JS basics.](/posts/coming-soon). I believe that in order to be considered an expert in a language, you must at least be able to demonstrate using the core language to achieve your goal. In our current case, HTTP routing. Now to be clear, I don't think you need to write everything from scratch all the time, but you should have a firm grasp on what is available by the core language, and when you are better suited to use an external library. If you are looking for more advanced HTTP routing, then I would suggest using something like [gin](https://github.com/gin-gonic/gin). @@ -48,7 +48,7 @@ Which basically means, `http.HandleFunc("/url", routingFunction)` where `routing With `fmt.Fprint()` we can pass an `http.ResponseWriter` and a message to display. Our browser will now look like this when we visit the `/url` endpoint. -![Browser Output for Step 2 - Hellp HTTP](step2-browser-output.png) +![Browser Output for Step 2 - Hellp HTTP](images/step2-browser-output.png) Here is what `main.go` looks like at this point: diff --git a/posts/step2-browser-output.png b/public/images/step2-browser-output.png similarity index 100% rename from posts/step2-browser-output.png rename to public/images/step2-browser-output.png