This is a case assignment for a Junior Platform Engineer position at ElBits AS. The task is to implement the last piece of a simple URL redirection service, and to deploy it.
TODO
-  Implement LinkFile.Load
- Deploy the application to fly.io.
- Ensure the gitcommand works.
- Clone this repository: git clone https://github.com/3lbits/case-url-shortener.git
- Install Go.
- Ensure the goandgofmtcommands work.
To check your implementation, run go test:
$ go test ./...This should give output like this:
ok  	github.com/3lbits/case-url-shortener	0.277sThe service runs as a small Go server. You can start it like this:
$ go run . -serve -addr ":9090" -linkfile links.txtYou can now send HTTP requests to the server:
$ curl -i localhost:9090/elbitsYou should get something that looks like this:
HTTP/1.1 500 Internal Server Error
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Fri, 04 Oct 2024 09:29:55 GMT
Content-Length: 14
implement me!
Links are stored in plain text files. Each line may contain either a comment, whitespace only, or a link definition.
- Lines containing only whitespace are ignored.
- Lines that start with a #character are ignored.
- Link definitions consist of any non-space characters, a space character, and a valid URL.
Here's an example file:
# Comments are useful
e https://elbits.no/
# lunch orders for Lede
lede-food-orders https://forms.google.com/sefyuaebrgoubaerogubaoeurfg82991384019401734
- Implement LinkFile.Long. It doesn't need to be fancy or optimized, it just needs to work.
- Deploy the application to fly.io.
A working HTTP server is implemented in main.go. You shouldn't need to change it.
You can modify any file except the existing test files in testdata and linkfile_pass_test.go.
If you do find any bugs in main.go or linkfile_pass_test.go, feel free to fix them and explain what you fixed in the commit message (this is not a test, we don't expect you to find anything specific).
We'll look at the bundled commit when evaluating the assignment.
You can commit directly to main.
Launch the application on fly.io. Create an account and follow the quickstart.
When told to run the flyctl launch command, you can provide this:
flyctl launch \
  --org "[UPDATE THIS]"
  --vm-size "shared-cpu-1x" \
  --region arn \
  --name urlshortener \
  --internal-port "8080" \
  --env "PORT=8080"Please send your app URL (flyctl deploy or flyctl launch should print this) together with the code bundle.
Run sh done.sh to generate finished-case.bundle and send it to case-url-shortener@elbits.no.
Enjoy!